Skip to content

perf(set): specialized-hash membership index results - #3

Merged
tannevaled merged 1 commit into
mainfrom
specialized-hash-perf
Jul 3, 2026
Merged

tannevaled merged 1 commit into
mainfrom
specialized-hash-perf

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Records the 2026-07-03 specialized-hash results for go-ruby-set/set and pins the benchmark to the feature commit.

Companion to the library PR go-ruby-set/set#2, which replaces the single map[any]struct{} membership index with a concrete-typed fast path (all int / all int64 / all string) plus a generic fallback — cutting the interface-hashing cost that kept build and union above MRI+YJIT, while preserving exact Ruby member identity (int(1), int64(1), 1.0, "1" stay distinct; a homogeneous set that gains a mixed-type member migrates to the generic map losslessly).

Results (best-of, Apple M4 Max, ruby 4.0.5 +PRISM / +YJIT)

op vs MRI vs YJIT verdict
intersection-1000 0.78× 0.82× beats MRI + YJIT
membership-1000 0.28× 0.74× beats MRI + YJIT
union-1000 1.07× 1.06× parity
build-1000 1.35× 1.33× honest floor

build/union residual is the two parallel insertion-order slices Go must keep because Go maps aren't insertion-ordered — the typed-map dedup alone is already ~MRI parity. Documented as the honest floor.

Reproducibility

  • benchmarks/go/go.mod now pins the library feature commit 2d4cab3 (pseudo-version v0.0.0-20260703173733-2d4cab35516f), verified to resolve from the proxy and reproduce the numbers.
  • Compiled bench binary added to .gitignore.

Important

The pin targets the feature commit on go-ruby-set/set#2. Please merge that PR with a merge commit (not squash) so 2d4cab3 stays reachable on main and this pin keeps resolving. If it is squashed, I will re-pin this go.mod to the resulting main pseudo-version.

🤖 Generated with Claude Code

…ion + membership

Record the 2026-07-03 specialized-hash results. The membership index gained a
concrete-typed fast path (int / int64 / string) with a generic fallback, cutting
the interface-hashing cost that kept build/union above MRI+YJIT.

Best-of (Apple M4 Max, ruby 4.0.5 +PRISM/+YJIT), vs MRI / vs YJIT:

  intersection-1000  0.78x / 0.82x  beats MRI + YJIT
  membership-1000    0.28x / 0.74x  beats MRI + YJIT
  union-1000         1.07x / 1.06x  parity
  build-1000         1.35x / 1.33x  honest floor (order slices Go maps lack)

Pin the benchmark go.mod to the feature commit so the numbers reproduce, and
gitignore the compiled bench binary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 5ed59bd into main Jul 3, 2026
@tannevaled
tannevaled deleted the specialized-hash-perf branch July 3, 2026 17:44
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