Skip to content

Replace ArrayBlockingQueue with park/unpark for BatchSpanProcessor$Worker#8240

Open
Khepu wants to merge 4 commits intoopen-telemetry:mainfrom
Khepu:main
Open

Replace ArrayBlockingQueue with park/unpark for BatchSpanProcessor$Worker#8240
Khepu wants to merge 4 commits intoopen-telemetry:mainfrom
Khepu:main

Conversation

@Khepu
Copy link
Copy Markdown

@Khepu Khepu commented Apr 1, 2026

Browsing through the codebase I saw the ArrayBlockingQueue and thought I could do something better. Running benchmarks locally did produce better results though they weren't as consistent as I would have liked.

The same changes could also be applied to BatchLogRecordProcessor.

Khepu added 2 commits April 1, 2026 21:40
Bypassing all the complexity that comes with ABQ should come with improved performance
@Khepu Khepu requested a review from a team as a code owner April 1, 2026 19:47
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 1, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.32%. Comparing base (c856c2b) to head (8970e4d).

Files with missing lines Patch % Lines
...telemetry/sdk/trace/export/BatchSpanProcessor.java 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8240      +/-   ##
============================================
- Coverage     90.32%   90.32%   -0.01%     
+ Complexity     7654     7653       -1     
============================================
  Files           843      843              
  Lines         23080    23076       -4     
  Branches       2312     2312              
============================================
- Hits          20848    20843       -5     
+ Misses         1516     1514       -2     
- Partials        716      719       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Making the worker extend thread was the only sensible way of having it keep a constant reference to its thread. Everything else I tried was quite hacky
@zeitlinger
Copy link
Copy Markdown
Member

Thanks for the contribution!

Please run the bench before/after and add results here - see #8271 on how to do it.

@Khepu
Copy link
Copy Markdown
Author

Khepu commented Apr 21, 2026

I've been running the benchmarks and I wonder if I am doing something wrong because every one of the BatchSpanProcessor benchmark files that does keep track of metrics for spans exported/dropped they end up being 0. Tested this before my changes too just to make sure I didn't break this by accident.

@jack-berg
Copy link
Copy Markdown
Member

Which ones did you try? Benchmarks collect dust and eventually get out of date, especially the ones not regularly used. Would RecordSpanBenchmark show the changes? That's one of the few that we run on an ongoing basis and publish results to https://open-telemetry.github.io/opentelemetry-java/benchmarks/

@Khepu
Copy link
Copy Markdown
Author

Khepu commented Apr 23, 2026

That one I can run just fine. I have been trying to run these 2:

SpanRecordBenchmark won't help here. I was trying the above 2 because all I am trying to improve is throughput of exported spans under load. The only metrics that could prove some improvement/regression here would be the number of exported and dropped spans.

I will try spending some time to figure out why those metrics end up being zero on those benchmarks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants