Optimize vector clock merge/compare/increment and binary serialization#32
Merged
dexcompiler merged 3 commits intomainfrom Feb 8, 2026
Merged
Optimize vector clock merge/compare/increment and binary serialization#32dexcompiler merged 3 commits intomainfrom
dexcompiler merged 3 commits intomainfrom
Conversation
Owner
Author
|
@copilot review |
Contributor
|
@dexcompiler I've opened a new pull request, #33, to work on those changes. Once the pull request is ready, I'll request review from you. |
Code review completed - VectorClock optimizations verified
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.
This PR improves
VectorClockperformance by reducing allocations and avoiding repeated lookups in the most common operations (Compare(VectorClock),Merge(VectorClock),Increment(ushort)) and by usingBinaryPrimitivesfor big-endian binary encoding/decoding. No behavior or wire-format changes are intended.Changes:
Compare(VectorClock): replaced HashSet + repeatedGet( )calls with a single linear merge-style walk over both sorted node-id arrays (allocation-free, O(n+m)).Merge(VectorClock): removedList<T>usage andToArray( )copies; now merges directly into pre-allocated arrays and trims to actual size.Increment(ushort): when incrementing an existing node, share the immutable node-id array and copy only the counters array; small copy optimizations for insert case.WriteTo(Span<byte>)/ReadFrom(ReadOnlySpan<byte>): useSystem.Buffers.Binary.BinaryPrimitivesfor big-endian reads/writes (same on-wire format).VectorClockXML comment from O(n) to O(n+m).