Repository navigation
perf: compare OID arcs for equality before ordering them - #58
Merged
Merged
Conversation
cmp.Compare makes two comparisons per arc, and most arcs of the OIDs a walk compares are equal. Testing for equality first restores the single comparison per equal arc that oidCompare made before it used cmp.Compare.
ilyam8
marked this pull request as ready for review
October 13, 2026 15:08
ilyam8
enabled auto-merge (squash)
October 13, 2026 15:13
vkalintiris
approved these changes
Oct 13, 2026
thiagoftsm
approved these changes
Oct 13, 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
Follow-up to the phase 6 re-evaluation. No behavior change.
oidComparecompares OIDs arc by arc. Since #56 it ordered each arc pair withcmp.Compare, which makes twocomparisons (
<, then>), where the loop before made one inequality test; most arcs of the OIDs a walk compares areequal, so every call paid for the extra comparison (+7.4% per call, measured against
fcca7b0). Testing for equalityfirst and calling
cmp.Compareonly for an arc pair that differs keeps thecmp.Compareform and removes the cost.A walk calls
oidCompareonce per value, so the effect on real walks is a few nanoseconds per value; it showed as+9-11% in
BenchmarkWalk, whose test agent finds each answer with a linearoidComparescan.Validation
TestOidCompareand the walk goldens unchanged; six mutants of the changed lines (inverted test, swappedarguments, no test, constant results, a one-sided test) all fail the tests.
BenchmarkWalk(8 interleaved rounds against docs: document the package, its known bugs, the README and the examples #57's merge):WalkAll-8.7%,BulkWalkAll-12.5%, back to theirtimes before refactor: tidy the request engine and API #56; bytes and allocations unchanged.