adapter: keep timestamp oracle round trips off the coordinator loop for object memory arrangements - #38915
Open
leedqin wants to merge 1 commit into
Open
adapter: keep timestamp oracle round trips off the coordinator loop for object memory arrangements#38915leedqin wants to merge 1 commit into
leedqin wants to merge 1 commit into
Conversation
Arrangement size history snapshotting moved its persist reads off the
coordinator loop, but three timestamp oracle round trips stayed on it.
The oracle is backed by the metadata store, so each call is a network
round trip with unbounded tail latency, and staging showed ~976ms p95 on
`arrangement_sizes_snapshot` once the feature was re-enabled.
The remaining round trips were:
* `schedule_arrangement_sizes_collection` awaited `peek_local_write_ts`
on entry. Sleeps are capped at `MAX_SLEEP`, so this re-entered every
60 seconds even while collection was disabled, and again on every
skip path.
* `arrangement_sizes_write` awaited `get_local_write_ts` once per
cycle to allocate a write timestamp used only as a display stamp,
never applied to a write.
* All four handlers were dispatched as futures via
`.boxed_local().await`.
Move the oracle peek into the task that already sleeps and snapshots, so
only the dyncfg read and the offset derivation run on the loop. Stamp
`collection_ts` from the snapshot's own `read_ts`, which is the state the
rows describe and is monotone across restarts via the oracle, and carry
it on `Message::ArrangementSizesWrite` instead of allocating a second
timestamp. This also drops an allocation that was never applied, and
matches the startup prune cutoff, which is already `read_ts` based.
With those gone the snapshot and write handlers have no await points and
prune never had any, so all four become sync fns and the dispatch arms
call them directly. The loop can no longer block on this path: a sync fn
cannot await, so the constraint is enforced by the compiler rather than
by review.
One nuance: `collection_ts` is no longer a uniquely allocated timestamp,
so two snapshots landing in the same millisecond would share one. That
is not reachable at the hourly production cadence.
leedqin
marked this pull request as ready for review
September 17, 2026 15:48
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.
Motivation
#37455 moved arrangement size history snapshotting's persist reads off the coordinator loop, but three timestamp oracle round trips stayed on it. The oracle is backed by the metadata store, so each call is a network round trip with unbounded tail latency. After the feature was re-enabled in staging,
arrangement_sizes_snapshotshowed ~976ms p95 on the Slow Coordinator Messages panel, against a target of <10ms for anything on the coordinator task.The remaining round trips:
schedule_arrangement_sizes_collectionawaitedpeek_local_write_tson entry. Sleeps are capped atMAX_SLEEP, so this re-entered every 60 seconds even while collection was disabled, and again on every skip path.arrangement_sizes_writeawaitedget_local_write_tsonce per cycle to allocate a write timestamp used only as a display stamp, never applied to a write..boxed_local().await.Changes
organization_id-seeded offset derivation stay on the loop.collection_tsis stamped from the snapshot's ownread_tsand carried onMessage::ArrangementSizesWrite, rather than allocating a second timestamp in the write handler.read_tsis the state the rows describe, is monotone across restarts via the oracle, and matches the startup prune cutoff, which is alreadyread_tsbased.The result is structural rather than incremental: a sync fn cannot await, so this path can no longer block the loop regardless of future edits, and the constraint is enforced by the compiler rather than by review.
Tests
No tests added or modified. This is a threading change with no intended behavior change, and it is covered by the existing
arrangement_sizesunit tests,test/testdrive/arrangement-sizes.td, andtest/restartworkflow_arrangement_sizes_stale_snapshot_after_restart.One behavioral nuance for reviewers: because the snapshot now runs entirely off-thread, a replica can go offline while it is in flight, so
arrangement_sizes_writerevalidates introspection freshness before appending and drops records from replicas that are no longer trusted.Follow-up
collection_tsis no longer a uniquely allocated timestamp, so two snapshots landing in the same millisecond would share one. Not reachable at the hourly production cadence.Verification that this actually clears the spike is post-deploy: re-enable
arrangement_size_history_collection_intervalin staging and confirm thearrangement_sizes_*series stay flat, with oracle tail latency appearing only inarrangement_sizes_collection_time_seconds.🤖 Generated with Claude Code