sim-rs: Add timestamp quantization and TX batching to sequential engine#824
Open
sandtreader wants to merge 2 commits intoprc/limit-tx-backlogfrom
Open
sim-rs: Add timestamp quantization and TX batching to sequential engine#824sandtreader wants to merge 2 commits intoprc/limit-tx-backlogfrom
sandtreader wants to merge 2 commits intoprc/limit-tx-backlogfrom
Conversation
The sequential engine was never quantizing timestamps, so each event had a unique timestamp and rayon parallelism never kicked in during TX-only periods. Two independent optimizations, each configurable separately: - Timestamp quantization: now applied to all events in the sequential engine, controlled by existing timestamp-resolution-ms (turbo.yaml sets 1.0ms) - TX batch generation: new tx-batch-window-ms config option batches all TX generation events within a time window into one timestamp (turbo.yaml sets 10ms). Independent of timestamp resolution. Also lowers parallel-threshold from 10 to 4 in turbo.yaml. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
The sequential DES engine was processing events almost entirely single-threaded during TX-only periods (near 0% CPU on a 32-core machine), only bursting to ~6 cores after EB production. Two root causes:
No timestamp quantization — the sequential engine never applied
timestamp-resolution-ms. Every TX arrival and network delivery had a unique timestamp, so the BSP batching processed ~360M events one at a time, never reachingparallel-thresholdfor rayon.One TX per event —
TxGeneratorCore::generate()produces one TX per call, each scheduled at a unique time. Even with quantization, TX inter-arrival times may span multiple quanta.Changes
Timestamp quantization in the sequential engine (
sim-core/src/sim/sequential.rs):Timestamp::with_resolution()— network deliveries, CPU task completions, timed events, and cross-shard messages.TX batch generation (new
tx-batch-window-msconfig option):TxGenerationhandler generates all TXs whose next scheduled time falls within the configured window, instead of one per event.timestamp-resolution-ms— works by comparing against an absolute window rather than quantized timestamps.turbo.yaml tuning:
timestamp-resolution-ms: 1.0(was effectively unused at 0.000001)parallel-threshold: 4(was 10)tx-batch-window-ms: 10.0(new)Performance impact
Tested on a 32-core machine with a 1500-slot CIP simulation:
Backward compatibility
All three optimizations are opt-in via turbo.yaml. Without it, defaults match previous behavior exactly:
timestamp-resolution-ms: 0.000001(no effective quantization)parallel-threshold: 10(unchanged)tx-batch-window-ms: null(disabled)actor, notsequentialTest plan
🤖 Generated with Claude Code