Skip to content

perf: compare OID arcs for equality before ordering them - #58

Merged
ilyam8 merged 1 commit into
masterfrom
oidcompare-fast-path
Oct 13, 2026
Merged

ilyam8 merged 1 commit into
masterfrom
oidcompare-fast-path

Conversation

@ilyam8

@ilyam8 ilyam8 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to the phase 6 re-evaluation. No behavior change.

oidCompare compares OIDs arc by arc. Since #56 it ordered each arc pair with cmp.Compare, which makes two
comparisons (<, then >), where the loop before made one inequality test; most arcs of the OIDs a walk compares are
equal, so every call paid for the extra comparison (+7.4% per call, measured against fcca7b0). Testing for equality
first and calling cmp.Compare only for an arc pair that differs keeps the cmp.Compare form and removes the cost.

A walk calls oidCompare once 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 linear oidCompare scan.

Validation

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
ilyam8 marked this pull request as ready for review October 13, 2026 15:08
@ilyam8
ilyam8 enabled auto-merge (squash) October 13, 2026 15:13
@ilyam8
ilyam8 merged commit 8ea16da into master Oct 13, 2026
20 checks passed
@ilyam8
ilyam8 deleted the oidcompare-fast-path branch October 13, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants