Bound instruments#8527
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (74.39%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #8527 +/- ##
============================================
- Coverage 90.96% 90.79% -0.17%
- Complexity 10207 10272 +65
============================================
Files 1013 1013
Lines 27160 27423 +263
Branches 3182 3205 +23
============================================
+ Hits 24706 24899 +193
- Misses 1730 1788 +58
- Partials 724 736 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
When discussing in the last java SIG, @trask brought up the point that perhaps the apparent 37% reduction in performance for threads=4,cardinality=128,temporality=cumulative,instrument=COUNTER_SUM case while the same case with cardinality=1 case improves is not expected, and might be caused test harness itself. Indeed this turned out to be the case. The multi-thread cases all record to the same set of series in the same order. #8550 fixes the benchmark, and this PR includes the changes from #8550 and uses benchmark figures from it as a baseline for comparison. I've updated the PR description with the new figures. The only remaining regression is in threads=4,cardinality=1,instrument=COUNTER_SUM,UP_DOWN_COUNTER_SUM. In these cases 4 threads hammer a single LongAdder and erode its striping. The results now match intuition. |
…y-java into bound-instruments
…telemetry-java into bound-instruments
…y-java into bound-instruments
|
Previously I reported that highly contended COUNTER_SUM, UP_DOWN_COUNTER_SUM cases showed a regression, which I attributed to higher contention on on the underlying LongAdder eroding its striping. However, after merging #8559, that regression has gone away. My read is that the real bottleneck the whole time was the volatile valuesRecorded, and that highly contended cases were actually increasing contention of writes to that field. So the principle of "more throughput exacerbates a hotspot, slowing it down" was right, but I misattributed the hotspot to be the LongAdder instead of valuesRecorded. The case for bound instruments looks even stronger now as they offer a benefit in all cases. |
Supersedes #8314.
Java implementation of open-telemetry/opentelemetry-specification#5050
Adds bound instrument support to
opentelemetry-api-incubator. Usage:In the original prototype #8314, I went with an API where bind returns the existing instrument interface. I.e. you call
LongCounter bind(Attributes)fromLongCounter. The user is meant to calladd(long), but the other methodsbind/add(long, Attributes),add(long, Attributes, Context)are still available. The user could call bind again without issue, but calling the add overloads which accept Attributes remove the performance gain.Instead, in this PR I've added dedicated
Bound{Type}{Instrument}interfaces, e.g:These are impossible to misuse, and allows for supporting a value + Context overload. Additionally, they lend themselves to extending later with a
close()method. Something that cannot be reasonably done if we reuse the existing instrument interfaces because whereas calling close on a bound instrument should only close that series, calling close on the instrument should either close all the series or have some sort of selector for the series that should be closed. The semantics are too different to reuse.In the original prototype #8314 I sketched out what it would look like in its final form with APIs added directly to the stable
opentelemetry-api. Here I've added it to the incubator such that its actually in a position to merge and evaluate.Performance characteristics
Main vs. PR — unbound instruments
No material change to the existing (unbound) record path — deltas are within run-to-run variance. The larger single-thread swings, e.g. cumulative last-value gauge, are a known high-variance cases.
Details
Bound vs. unbound instruments
Bound recording has improvements across the board, with most improvement in uncontended cases. There are small reductions in a few cases that are within the benchmark error margin I've been seeing.
Details