[comparison draft] unsafe update-combiner throughput ceiling PoC - #1503
Draft
snissn wants to merge 5 commits into
Draft
[comparison draft] unsafe update-combiner throughput ceiling PoC#1503snissn wants to merge 5 commits into
snissn wants to merge 5 commits into
Conversation
43 tasks
This was referenced Jun 2, 2026
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.
Summary
Comparison-only draft throughput proof-of-concept for issue #1500: sharded update-combiner lane workers now prepare direct buffered update plans concurrently by document-ID shard, then merge compatible prepared plans back into one global buffered/publish path.
This intentionally validates throughput headroom first and is not a merge-to-main candidate as-is. It is stacked on
codex/update-combine-bsonset-id-fastpathand should remain draft/profiling-only until the production conflict protocol is implemented.Comparison branch boundary
main, add explicit conflict handling, read visibility, backpressure, and durability semantics.What changed
CollectionManager.SetUpdateCombineLaneWorkersForProfiling.indexed_flush_calls=1andindexed_flush_docs/batch=100000.cmd/mongo_gateway_bench:MONGO_GATEWAY_PROFILE_BENCH_UPDATE_COMBINE_SHARDS=NMONGO_GATEWAY_PROFILE_BENCH_UPDATE_COMBINE_LANE_WORKERS=trueMONGO_GATEWAY_PROFILE_BENCH_UPDATE_COMBINE_UNSAFE_STALE_DIRECT_PLANS=trueSafety boundary
This is not a production correctness contract yet.
The
MONGO_GATEWAY_PROFILE_BENCH_UPDATE_COMBINE_UNSAFE_STALE_DIRECT_PLANS=trueflag allows controlled benchmark runs to stage direct buffered update plans that were built before another lane advanced the buffered generation. Use it only for shapes with non-overlapping document IDs and unchanged unique secondary indexes.Before making this production, the next PR needs explicit conflict/hot-key handling: per-document serialization, duplicate-key fallback, unique-secondary-change fallback, and transaction/coordinator boundaries.
Benchmark evidence
Command family used for the post-cleanup comparison:
Artifacts:
/tmp/gomap_lane_merge_poc_sweep_20260513_100859/sweep.txt/tmp/gomap_lane_merge_poc_post_stats_compare_20260513_101424/compare.txtPost-cleanup 3-run averages:
Relative throughput:
334,393 / 189,888 = +76.1%369,188 / 192,928 = +91.4%Earlier full writer sweep showed the same scaling shape across concurrency:
Validation
GOWORK=off go test ./TreeDB/collections ./cmd/mongo_gateway_bench git diff --checkProfile pass: lane-batching tune
Additional commit:
fef3c11a tune sharded update combiner lane batching.I profiled the current PoC at 64 writers with CPU, heap/alloc, block, and mutex profiles.
Artifacts:
/tmp/gomap_update_combiner_poc_cpuonly_20260513_103021/tmp/gomap_update_combiner_poc_profiles_20260513_102904/tmp/gomap_lane_drain16_compare_20260513_103140/tmp/gomap_lane_drain4_compare_20260513_103243/tmp/gomap_lane_drain2_compare_20260513_103325/tmp/gomap_lane_pool_drain4_compare_20260513_103510Profile summary:
runShardWorker -> prepareBatchWithScratch -> buildUpdateBatchPlan.$setreplacement work, not publish lock contention.Tuning kept:
1scheduler yield to a lane-only4yields.Drain-tuning evidence, 100k docs, 3-run averages:
For comparison, the prior post-cleanup lane-merge run averaged 369,188 docs/sec at 64 writers. The drain=4 tune improved the high-concurrency average in this sample while keeping the same safety boundary and one final indexed flush.
Experiment rejected:
defaultCollectionUpdateCombineLaneDrainYields=16increased batch size but added too much drain delay; 64-writer throughput fell to 317,384 docs/sec.Next obvious walls after this PoC:
buildUpdateBatchPlanfor non-overlapping$setupdates.$setpath.Profile pass: unsafe async foreground-ack ceiling
Additional commit:
76c84849 add unsafe async update ack profiling mode.This adds a profiling-only
MONGO_GATEWAY_PROFILE_BENCH_UPDATE_COMBINE_UNSAFE_ASYNC_ACK=truemode. In that mode, the foreground update path returns after the request is admitted to the sharded combiner queue. Lane workers still drain the queued requests, prepare real BSON$setupdate plans, stage them, and the benchmark then timesDrainUpdateCombinersForProfiling()plusFlushAll()separately inside the measured window.This is intentionally not a durability or visibility contract. It exists to measure the gap between foreground admission throughput and background update/root-publish drain throughput.
Command shape:
Artifacts:
/tmp/gomap_update_async_ack_poc_20260513_115800/tmp/gomap_update_async_ack_profiles_20260513_115830/tmp/gomap_update_async_ack_nolock_20260513_120032Representative results, 300k docs:
Profile conclusion:
buildUpdateBatchPlan, current-document read, BSON$setreplacement, staging, and final root publish.runShardWorker -> prepareBatchWithScratch -> buildUpdateBatchPlan, withreadUpdateBatchCurrentDocument/Tree.GetAppendas the main storage-read component.