[chore][processor/batchprocessor] Improve batch processor edge case performance#13272
Closed
asweet-confluent wants to merge 3 commits into
Closed
[chore][processor/batchprocessor] Improve batch processor edge case performance#13272asweet-confluent wants to merge 3 commits into
asweet-confluent wants to merge 3 commits into
Conversation
8d11cbe to
051a987
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13272 +/- ##
=======================================
Coverage 91.95% 91.96%
=======================================
Files 529 529
Lines 31446 31513 +67
=======================================
+ Hits 28917 28981 +64
- Misses 1998 2000 +2
- Partials 531 532 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
6 tasks
atoulme
reviewed
Jul 15, 2025
atoulme
reviewed
Jul 15, 2025
As the batch size approaches one, the time complexity of the batch processor approaches O(n^2). This is caused by repeatedly counting the number of data points in a message. This commit introduces a "short-circuit" behavior that allows the core loop to exit quickly when the desired number of data points has been found.
051a987 to
5af55af
Compare
Contributor
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Contributor
Contributor
Contributor
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Contributor
|
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
As the batch size approaches one, the time complexity of the batch processor approaches O(n^2). This is caused by repeatedly counting the number of data points in a message. This commit introduces a "short-circuit" behavior that allows the core loop to exit quickly when the desired number of data points has been found.
Testing
Performance
I added a new benchmark for
splitMetricsthat tests performance with various numbers of metrics and a batch size of one. This is the before and after comparison produced bybenchstat:goos: linux goarch: amd64 pkg: go.opentelemetry.io/collector/processor/batchprocessor cpu: 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ TraceSizeSpanCount-16 3.326n ± 13% 3.181n ± 5% -4.37% (p=0.011 n=20) BatchMetricProcessor-16 366.9µ ± 8% 416.7µ ± 7% +13.58% (p=0.003 n=20) MultiBatchMetricProcessor-16 419.6µ ± 6% 404.8µ ± 3% -3.54% (p=0.021 n=20) SplitMetrics1k-16 4.063m ± 7% 1.264m ± 4% -68.88% (p=0.000 n=20) SplitMetrics16k-16 841.3m ± 3% 189.4m ± 2% -77.48% (p=0.000 n=20) SplitMetrics64k-16 17.599 ± 5% 3.203 ± 9% -81.80% (p=0.000 n=20) geomean 1.771m 862.5µ -51.29%I am surprised to see
BatchMetricProcessor-16performance regress here - does anyone have an idea of why that might be? I'll dig into it a bit more as well.Correctness
I'm relying on the existing test suite to catch issues here.