Skip to content

perf(telemetry): serialize batches on shared thread pool - #1946

Open
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/perf/telemetry-pool
Open

perf(telemetry): serialize batches on shared thread pool#1946
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/perf/telemetry-pool

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Let the telemetry module own a shared thread pool for telemetry batchers, and use it for log and metric batch serialization.

image

Before: on the left, the batcher thread is unable to keep up with serializing incoming logs before handing them off to the transport thread. Serialization takes too much time, queues fill up, logs overflow, and get discarded. The batcher thread continues working for a good while after logs stop coming in.

After: on the right, the batcher thread only acts as a gateway for incoming logs. It has no problem keeping up with the flood because they are only quickly organized into batches and immediately handed over to the telemetry pool, which then distributes the heavy serialization work to its pooled threads, resulting in no discarded logs.

before-vs-after.ftrace.zip

A partial, batcher-side fix to:

Comment thread src/sentry_batcher.c
Comment thread src/sentry_batcher.c
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.10801% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.54%. Comparing base (38fb099) to head (2f2e296).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1946      +/-   ##
==========================================
+ Coverage   74.31%   74.54%   +0.23%     
==========================================
  Files         104      104              
  Lines       25738    25966     +228     
  Branches     4648     4688      +40     
==========================================
+ Hits        19126    19357     +231     
+ Misses       5305     5299       -6     
- Partials     1307     1310       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from ae3b36a to 53a8c3e Compare August 4, 2026 11:44
Comment thread src/sentry_batcher.c
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from 53a8c3e to e8103ca Compare August 4, 2026 12:37
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from e8103ca to af6d19c Compare August 4, 2026 13:51
Comment thread src/sentry_batcher.c
Comment thread src/sentry_batcher.c Outdated
Comment thread src/sentry_batcher.c
Comment thread src/sentry_batcher.c
Comment thread src/sentry_telemetry.c
Comment thread src/sentry_batcher.c
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from 7e20632 to ccf9950 Compare August 5, 2026 09:46
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from ccf9950 to a5e9fef Compare August 5, 2026 10:14
Comment thread src/sentry_batcher.c
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from a5e9fef to bd10425 Compare August 6, 2026 08:17
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from bd10425 to 9cb4261 Compare August 6, 2026 10:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9cb4261. Configure here.

Comment thread src/sentry_batcher.c
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from 261cfe1 to 1134ee2 Compare August 6, 2026 14:46
Base automatically changed from jpnurmi/perf/thread-pool to master August 12, 2026 14:03
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from 1134ee2 to ba1a0c2 Compare August 12, 2026 14:18
@jpnurmi jpnurmi changed the title [WIP] perf(telemetry): serialize batches on shared thread pool perf(telemetry): serialize batches on shared thread pool Aug 12, 2026
Comment thread src/sentry_telemetry.c Outdated
@jpnurmi
jpnurmi marked this pull request as draft August 14, 2026 06:54
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from c068550 to f908079 Compare August 14, 2026 08:12
@jpnurmi

jpnurmi commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

Update: I'm investigating why TSAN jobs started hanging in the CI after the latest rebase and max_pending changes. I haven't been able to reproduce locally... :(

@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from 3d7e429 to 089103a Compare August 14, 2026 14:47
Revert 219d934, which promoted the page allocator spinlock into a shared
primitive. The page allocator and telemetry batcher require different locking
semantics and should not share this implementation.
Let the telemetry lifecycle own a shared serialization pool for enabled
telemetry batchers.

Use the pool for log and metric batch serialization while keeping completion
ordered through the batcher flush lifecycle.
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/telemetry-pool branch from 089103a to 2f2e296 Compare August 14, 2026 20:13
@jpnurmi
jpnurmi marked this pull request as ready for review August 15, 2026 07:58
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.

1 participant