Repository navigation
perf(6o-i): cheaper group framing: a byte-loop record check, prebuilt markers, one shared group extent - #200
Merged
Merged
Conversation
… markers, one shared group extent The 6O-I campaign (PR 6) measured the grouped AOF path at +5-7.5% server CPU per transaction, about 52 ns per member: the one-record check each member gets in every build (review A L6) parsed every length with a window search and str::parse. It now reads digits byte by byte, with the same acceptance (plus a sign now refused, which RESP never writes) and unit tests of its own. TXN-BEGIN/TXN-COMMIT for groups of up to 64 records come from a table built once instead of being formatted per EXEC. The same campaign measured +6 to +13 MiB of primary RSS with a replica attached: every backlogged frame carried a 32-byte group extent (review A N3). A group's frames now share one Arc'd extent: 8 bytes per frame.
…bytes The re-measurement showed the shared Arc extent helps large groups only (primary RSS with a replica, 100-write transactions: 71 -> 62 MiB, base 59) but not 2-frame ones (72 -> 68 MiB, base 59): 8 bytes inline plus half of a 48-byte allocation per frame. GroupMark is 16 bytes inline, no allocation: the first offset (NonZeroU64), the count, and the byte total saturating at u32::MAX (a group that large is refused by every capable replica, whose bound is 64 MiB, so the header it then declares leads to the same full sync).
… a single write allocates nothing more Review E (H2, M2): every replicated write paid for 6O-I. A backlogged frame carried a group extent (16 to 32 bytes, grouped or not: +7 to +13 MiB of primary RSS over a full 16 MiB backlog of small frames, growing with the backlog setting), and fan_out built two Vecs for one frame. - ReplFrame is back to 16 bytes. The backlog keeps one ReplGroup per group in a side table (oldest first, kept while any of its frames is), which rule 2 consults (group_of, a binary search); a partial sync gets the groups that start among its frames. - A queued frame carries the group only on the group's first frame, for the sender's header. - publish takes a SmallVec: fan_out of one frame allocates nothing more than before 6O-I. - The byte total is u64 again: no saturation.
L5: no test or mutant covered the side table's trim; a table that never shrank passed every test. The new test fans out 10,000 two-frame groups (and single writes) into a 1,000-byte backlog and checks after each that no group without a retained frame stays and that the table stays bounded. It fails with the trim removed.
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.
Phase 6O-I: reduces the transaction-framing costs that PR 6's native campaigns measured. Draft until review E (performance and resources) approves it. Review E round 1 found the code correct and asked for the measurements now running.
What was measured
Base 6O-H
6068337against 6O-Idev0a1f95e, 5 interleaved reps:everyseccost +5–8% server CPU per transaction, about 48–62 ns per member.everyseclost 9–11% throughput.fan_out.Changes
617aedb. The one-record check each grouped member gets in every build (review A L6) reads lengths byte by byte. Its acceptance is the same, except that a
+sign is now refused (RESP never writes one), and it has unit tests.TXN-BEGIN/TXN-COMMITfor groups of 2–64 records come from a table built once.4d46dbc. An intermediate inline 16-byte group mark, superseded by the next commit.
976574a. Groups live in a side table beside the backlog, one 24-byte entry per group, kept while any of its frames is.
ReplFrameis back to 6O-H's 16 bytes, so a non-transactional write pays nothing for 6O-I. Rule 2 does a binary search of the side table, a partial sync gets the groups that start among its frames, and a queued frame carries the group only on the group's first frame.fan_outof one frame uses an inlineSmallVec, so it allocates nothing more than before 6O-I. The byte total isu64again, with no saturation.785f042. A test only (review E round 2, L5): the side table is trimmed with the backlog. It fails with the trim removed.
Verification
976574a.V0.6O-I-PERFORMANCE.md).976574a. Text:benchmarks/v0.6.0/6o-i/raw/i5-review/REVIEW-E-round2.mdin bench(6o-i): validation, performance and release gate (PR 6) #201. With perf(6o-i): cheaper group framing: a byte-loop record check, prebuilt markers, one shared group extent #200, two-writeeverysectransactions go from +8.7% to +3.8% CPU (0.91× to 0.934× throughput on the HDD), and the primary's RSS with a replica from +12–13 to +3–5 MiB.