Skip to content

Skip the tag-dictionary walk in IndexName equality when tags are identical#224

Merged
mtfishman merged 1 commit into
mainfrom
mf/indexname-identity-shortcircuit
Jul 20, 2026
Merged

Skip the tag-dictionary walk in IndexName equality when tags are identical#224
mtfishman merged 1 commit into
mainfrom
mf/indexname-identity-shortcircuit

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

Adds a === fast path to == and isequal on IndexName so a comparison skips the tag-dictionary walk when both names carry the same tags object. An index leg reused across tensors carries the same IndexName, and therefore the same tags container, so the common equal case drops from walking the tag dictionary to a single pointer check.

The check sits on the tags field, which is the only costly one to compare: uuid and plev stay as the cheap primary discriminators, so names with a different id or prime level short-circuit before reaching the tags at all. This is sound because the tags are SortedDict{Symbol, Symbol} and Symbol equality is reflexive, so identical tag objects always compare equal.

Comparing two two-tag IndexNames (Julia 1.12, minimum of @benchmark, zero allocations), the equal case where both names carry the same tags object drops from about 6.5 ns to 2.7 ns. The other paths are unchanged: names with a different id short-circuit on the uuid comparison at about 3 ns, and names with different tags fall through to the full dictionary walk at about 6 ns.

…entical

## Summary

Adds a `===` fast path to `==` and `isequal` on `IndexName` so a comparison skips the tag-dictionary walk when both names carry the same tags object. An index leg reused across tensors carries the same `IndexName`, and therefore the same tags container, so the common equal case drops from walking the tag dictionary to a single pointer check (roughly 6.5 ns to 2.7 ns for a two-tag name).

The check sits on the tags field, which is the only costly one to compare: `uuid` and `plev` stay as the cheap primary discriminators, so names with a different id or prime level short-circuit before reaching the tags at all. This is sound because the tags are `SortedDict{Symbol, Symbol}` and `Symbol` equality is reflexive, so identical tag objects always compare equal.
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.90%. Comparing base (e82817e) to head (f5809a0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #224   +/-   ##
=======================================
  Coverage   76.90%   76.90%           
=======================================
  Files          29       29           
  Lines        1706     1706           
=======================================
  Hits         1312     1312           
  Misses        394      394           
Flag Coverage Δ
docs 26.36% <100.00%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtfishman
mtfishman enabled auto-merge (squash) July 20, 2026 21:35
@mtfishman
mtfishman merged commit 412dfa9 into main Jul 20, 2026
18 checks passed
@mtfishman
mtfishman deleted the mf/indexname-identity-shortcircuit branch July 20, 2026 21:38
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.

1 participant