perf: add enqueue_many so a wide record takes one buffer lock, not one per channel - #322
Merged
Conversation
alxhill
approved these changes
Aug 26, 2026
This was referenced Aug 26, 2026
…e per channel Writing N channels at one timestamp meant N capacity reservations and N buffer lock acquisitions, one per channel, even though they all belong in the same request. `enqueue_many` admits the whole batch under one reservation and one lock. A batch larger than `max_points_per_record` is admitted in pieces rather than all at once, so a single call can neither build a request larger than that limit nor hold the buffer lock for longer than a record's worth of work. `has_capacity` deliberately lets an oversized batch into an empty buffer, which is right for one channel's series but wrong for a batch assembled from thousands of channels, where nothing else would bound it. A batch that already fits -- the case this exists for -- is admitted whole, so a wide record keeps the guarantee that all its channels share a request, and one channel's series is still never split. Measured against the staging backend on top of the direct-enqueue change, 6,480 channels at one timestamp, interleaved A/B over three rounds: CPU per million points 0.487s -> 0.437s ~10% less throughput 2.12 Mp/s -> 2.17 Mp/s within noise; staging is network-bound here Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
drake-nominal
force-pushed
the
perf/enqueue-many
branch
from
August 27, 2026 01:07
e95d480 to
7bc9ba8
Compare
Merged
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.
Stacked on #320. Core-crate change — additive, no existing signature changes.
What it does
Writing N channels at one timestamp took N capacity reservations and N buffer lock acquisitions,
one per channel, though they all belong in the same request.
enqueue_manyadmits the batch underone reservation and one lock.
Oversized batches are admitted in pieces capped at
max_points_per_record, so one call can neitherbuild a request larger than that limit nor hold the buffer lock longer than a record's worth of
work.
has_capacitydeliberately lets an oversized batch into an empty buffer — correct for asingle channel's series, but wrong for a batch assembled from thousands of channels, where nothing
else bounds it. A batch that already fits is admitted whole, so a wide record keeps the guarantee
that its channels share a request, and one channel's series is never split across requests.
Results
Against the staging backend, on top of #320, 6,480 channels at one timestamp, interleaved A/B
over three rounds:
Throughput is unchanged because staging is network-bound at this rate — the win here is CPU. Set
expectations accordingly: this is a modest, real improvement on top of #320's 4.6x, not another
multiple.
Tests
Three new unit tests: every channel of a wide record lands in one request; an oversized batch is
split with no request exceeding
max_points_per_recordand no points lost; and a channel reachedthrough both
enqueueandenqueue_manyshares one series rather than splitting.🤖 Generated with Claude Code