Skip to content

perf(batcher): configurable rotating telemetry buffers - #1867

Merged
jpnurmi merged 6 commits into
masterfrom
jpnurmi/perf/log-buffers
Jul 16, 2026
Merged

jpnurmi merged 6 commits into
masterfrom
jpnurmi/perf/log-buffers

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is built around the following documented constraints:

Note

SDKs MUST NOT send more than 100 logs per envelope (since 1.15.0). Relay is optimized for this limit.

SDKs MUST enforce a hard limit of 1000 queued log events to prevent out-of-memory issues (since 1.12.0). Logs added beyond this limit are dropped. SDKs MAY use a lower limit but MUST NOT exceed 1000.

https://develop.sentry.dev/sdk/telemetry/logs/#buffering

This PR increases the default telemetry buffer capacity from 2x100 to 3x100, which is a 50% increase in the relatively low burst capacity, while keeping the required limit of 100 logs per envelope.

The number of buffers is now configurable via SENTRY_BATCHER_BUFFER_COUNT. A minimum of 2 is available for memory-constrained builds for low-end devices. For burst-heavy integrations, such as debug-level UE_LOG, the number of buffers can be increased up to 10, matching the documented hard limit of max 1000 queued logs.

Tip

Each additional buffer retains another 100 items while the batcher thread catches up, but its storage is reserved in each logs and metrics batcher even when empty (roughly 0.8 KiB per empty 100-item buffer).

Details: why it got so complicated?

Simply adding more buffers would not have increased the usable capacity. The original implementation only alternated between two fixed buffers, and only the consumer selected the next buffer when flushing; producers never advanced the active buffer, so any additional buffers would never be used. Producers now rotate through the configured buffers as soon as one becomes full. This also reduces drops by removing the delay between filling a buffer and the consumer waking up to rotate it. Supporting this requires tracking the oldest buffer for FIFO draining and synchronizing rotation with in-flight writers so buffers are not drained or reused prematurely.

Related to:

Comment thread src/sentry_batcher.c Resolved
Comment thread src/sentry_batcher.c Resolved
@jpnurmi jpnurmi changed the title perf(logs): triple buffer to increase burst capacity perf(batcher): configurable rotating telemetry buffers Jul 15, 2026
jpnurmi added 5 commits July 15, 2026 12:24
Seal the old buffer before publishing the new active buffer, and treat a
concurrent rotation as successful so the final flush does not skip queued
items.
Add a validated CMake option for selecting two to ten 100-item
telemetry buffers while retaining three as the default. Document the
memory and burst-capacity tradeoff.
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/log-buffers branch from 007e826 to ea67370 Compare July 15, 2026 10:33
@jpnurmi jpnurmi mentioned this pull request Jul 16, 2026

@JoshuaMoelans JoshuaMoelans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice rework 👌

@jpnurmi
jpnurmi merged commit d50befe into master Jul 16, 2026
164 of 175 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/perf/log-buffers branch July 16, 2026 11:48
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
sentry-native 0.15.4

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.

- [ ] `resource` blocks have been checked for updates.
<details>
  <summary>release notes</summary>
  <pre>**Features**:

- Add reusable, user-owned scopes. `sentry_scope_new` creates a scope that `sentry_capture_event_with_scope` applies without consuming, so you can configure it once and reuse it across many captures instead of building a new local scope each time. `sentry_scope_clone` copies a scope, and `sentry_scope_free` releases it. ([#1855](getsentry/sentry-native#1855))
- Android: Expose setting the environment on the scope through the NDK bindings via `NativeScope.setEnvironment()`, so head SDKs can sync the environment at runtime. ([#1874](getsentry/sentry-native#1874))
- Embed the crash event's breadcrumbs into session replay recordings, so breadcrumbs from the replay window show up on the replay timeline. ([#1875](getsentry/sentry-native#1875))
- Add `sentry_transaction_discard` and `sentry_span_discard` for releasing unfinished transactions and spans without sending them. ([#1858](getsentry/sentry-native#1858))
- Add scope attributes. `sentry_scope_set_attribute` / `_n` set an attribute on a scope and `sentry_scope_remove_attribute` / `_n` remove one, while the new `sentry_scope_capture_log` and `sentry_scope_capture_metric` capture a log or metric against a given scope. Scope attributes and trace are applied to logs and metrics captured against it, resolving most-specific-first: per-call data, then the scope, then the global scope. ([#1861](getsentry/sentry-native#1861))
- Add `sentry_scope_clear` to reset a scope's data. ([#1881](getsentry/sentry-native#1881))

**Deprecations**:

- Deprecate `sentry_capture_event_with_scope` in favor of `sentry_scope_capture_event` (scope first), which matches `sentry_scope_capture_log` / `sentry_scope_capture_metric`. ([#1882](getsentry/sentry-native#1882))

**Fixes**:

- Apply the propagation context to events that already have contexts set, so that events captured with a local scope or with event-level contexts keep their trace. ([#1843](getsentry/sentry-native#1843))
- Crashpad: reject runtime control IPC from processes other than the one that started the handler. ([#1853](getsentry/sentry-native#1853))
- Native/macOS: resolve symbol names for crash stacktraces from Mach-O symbol tables and dSYM companions. ([#1856](getsentry/sentry-native#1856))
- Route libcurl debug output through the Sentry logger (`SENTRY_TRACE`) instead of writing to `stderr`. ([#1854](getsentry/sentry-native#1854))
  - NOTE: `sentry_options_set_debug(options, true)` no longer displays verbose libcurl debug output by default. To restore it, call `sentry_options_set_logger_level(options, SENTRY_LEVEL_TRACE)`.
- Crashpad: route client logs through the Sentry logger to make actionable handler startup errors visible. ([#1859](getsentry/sentry-native#1859))
- Windows: fix symlink detection used to prevent database cleanup from following symlinks in run and cache directories. ([#1857](getsentry/sentry-native#1857))
- Linux: avoid unsafe `copy_file_range` at crash time. ([#1868](getsentry/sentry-native#1868))
- Increase the default telemetry batcher capacity from 2x100 to 3x100 items, and add `SENTRY_BATCHER_BUFFER_COUNT` to configure the number of rotating buffers used by log and metric batchers. ([#1867](getsentry/sentry-native#1867))
- Fix a lifetime issue when reading `sample_rand` from the scope propagation context. ([#1869](getsentry/sentry-native#1869))
- Linux: silence harmless compilation warnings in `sentry_modulefinder_linux.c` and `sentry_backend_inproc.c`. ([#1871](getsentry/sentry-native#1871))
- Fix per-call log and metric attributes to override same-named global attributes atomically, preventing fields such as `unit` from leaking from the global attribute when the per-call attribute does not define them. ([#1879](getsentry/sentry-native#1879))
- Prefix vendored mpack symbols to avoid symbol conflicts. ([#1880](https://github.com/getsentry/sentry-native/pull/1880))</pre>
  <p>View the full release notes at <a href="https://github.com/getsentry/sentry-native/releases/tag/0.15.4">https://github.com/getsentry/sentry-native/releases/tag/0.15.4</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!14800
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