Repository navigation
perf(partitions): spread WAL checkpoint starts across partitions - #5113
krishvishal wants to merge 1 commit into
Conversation
A partition starts a WAL checkpoint once its byte budget is half full. Under equal load the partitions reach that mark together, so all shards checkpoint in the same second and every partition stalls at once. With 25 partitions on 8 shards, 18 checkpoints started in one second, once every 50 s, and those seconds held the worst latency of the run. The mark is now drawn per partition from 3/8 to 5/8 of the budget, and drawn again after each checkpoint so no partition keeps a low mark. The average checkpoint rate rises by about 2%. The mark stays at least one maximum-size prepare below the budget, so an append that does not fit always finds a checkpoint due. Local OMB, one node, replicated: publish p99.9 went from 6.9 to 3.8 ms and max from 61 to 15 ms on 25 partitions with one message per batch. 12 partitions at 125 MB/s did not change.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## journal-checkpoint-segment-paths #5113 +/- ##
======================================================================
+ Coverage 88.77% 92.26% +3.49%
Complexity 4366 4366
======================================================================
Files 1570 1592 +22
Lines 366680 436888 +70208
Branches 294913 365122 +70209
======================================================================
+ Hits 325515 403105 +77590
+ Misses 34869 28170 -6699
+ Partials 6296 5613 -683
🚀 New features to boost your workflow:
|
| // The minimum budget is two records of the largest prepare. | ||
| let largest_record = PARTITION_WAL_CAPACITY_MIN / 2; | ||
| let offset = splitmix64(splitmix64(group) ^ checkpoint_op) % (capacity / 4 + 1); | ||
| (capacity / 8 * 3 + offset).min(capacity.saturating_sub(largest_record)) |
There was a problem hiding this comment.
[nit] At the minimum budget of 128 MiB + 8 KiB this cap equals capacity / 2, so half the draws clip to exactly the old fixed mark and those partitions still start checkpoints together. The clip lasts up to about 171 MiB, yet the doc comment above and core/server/config.toml:1127 state 3/8 to 5/8 for every budget.
| const CHECKPOINTS: u64 = 1000; | ||
| let capacity = PARTITION_WAL_BYTES_MAX; | ||
| let group = IggyNamespace::new(1, 1, 0).inner(); | ||
| // Checkpoints per byte against a mark at half, in thousandths: a |
There was a problem hiding this comment.
[nit] Summing half / mark per checkpoint gives about 1.02, but that is the rate of marks fixed per partition. With a redrawn mark, a partition checkpoints once per mean mark, which is exactly half, so its rate equals the old one, as the test name says. The 1000..1040 range accepts both, and the PR body repeats the 2% claim.
| && (self.checkpoint_needed.get() | ||
| || self.retained_bytes.get() + self.queued_bytes.get() + self.in_flight_bytes.get() | ||
| >= self.capacity / 2 | ||
| >= checkpoint_bytes(self.capacity, self.group, self.checkpoint.get()) |
There was a problem hiding this comment.
[nit] Moving the trigger leaves core/integration/tests/server/disk_usage.rs:57 saying the 18.3 MiB burst is measured against half the 256 MiB budget. The lowest mark is now 3/8, which is 96 MiB. The test still holds, but its comment names a trigger that no longer exists.
Rationale
Every partition started a WAL checkpoint once its byte budget was half full. Under equal load the partitions reach that mark together, so all shards checkpoint in the same second and every partition stalls at once. With 25 partitions on 8 shards, 18 checkpoints started in one second, once every 50 s, and those seconds held the worst latency of the run.
What changed?
The mark is now drawn per partition from 3/8 to 5/8 of
wal_bytes_max, and drawn again after each checkpoint. A mark fixed per partition left some partitions with a low mark for good, which cost 7-10% more checkpoints in the benchmark. Redrawn, the rate rises by about 2% on average, and the runs below took 2-7% more checkpoints. The mark stays at least one maximum-size prepare below the budget, so an append that does not fit always finds a checkpoint due.Local Execution
crash_durability,partition_dedup,idempotent_producer)replicated, perf(journal): stop formatting a path per WAL entry at checkpoint #5106 vs this branch, 2 runs each, alternatedOn 25 partitions, p99.9 fell by 44% and max by 76%. The busiest second went from 18 checkpoint starts to 3.
12 partitions is neutral: only 4-9 checkpoints started in the same second there, so there was less to spread. In run 1 of this branch, one 20 s window took outside CPU load: machine-wide CPU rose from 19% to 28-44% while checkpoints ran as usual.