Skip to content

deps: bump go-ruby-prime to segmented-sieve fix (Prime.each 12.7x->1.4x MRI) - #113

Merged
tannevaled merged 1 commit into
mainfrom
perf/bump-prime-sieve
Jul 3, 2026
Merged

tannevaled merged 1 commit into
mainfrom
perf/bump-prime-sieve

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Consumes go-ruby-prime#1 (memoized segmented int64 sieve). rbgo's go.mod still pinned the pre-fix pseudo-version so the shipped interpreter kept the slow per-candidate Baillie-PSW enumeration.

Measured end-to-end through rbgo (harness prime.enum_factor, warm): ~135900 ns/op (12.68x MRI) -> ~15300 ns/op (1.41x MRI). Enumeration now fast; residual is factorization + binding.

Dep-bump only; MRI-parity semantics preserved by go-ruby-prime#1 (differential oracle stays green).

🤖 Generated with Claude Code

…->1.4x MRI)

go-ruby-prime#1 replaced the per-candidate Baillie-PSW generator with a
memoized segmented int64 sieve (MRI-parity semantics). rbgo's go.mod
still pinned the pre-fix pseudo-version, so the shipped interpreter kept
paying the slow enumeration. Bump to the merged main pseudo-version:
Prime.each_factor drops from ~135900 ns/op (12.68x MRI) to ~15300 (1.41x)
measured end-to-end through rbgo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 75b7455 into main Jul 3, 2026
9 checks passed
@tannevaled
tannevaled deleted the perf/bump-prime-sieve branch July 3, 2026 11:40
tannevaled added a commit that referenced this pull request Jul 3, 2026
This branch predated #113 (the go-ruby-prime segmented-sieve bump), so its
go.mod still pinned the pre-fix version. Match main's pin so merging this
PR does not regress Prime.each back to ~12.8x MRI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tannevaled added a commit that referenced this pull request Jul 3, 2026
…114)

* perf(vm): int64 fast path + batched arg-boxing for sprintf/String#%

The format binding routed every operand through the go-ruby-format
Value interface, and every integer through math/big: a profile of a
sprintf-heavy loop showed the format path was GC-bound on those
allocations (not on re-parsing the format string).

Two allocation cuts on the Kernel#sprintf / Kernel#format / String#%
path:

  * formatValue implements the library's Int64Fast fast-path, so a
    native Integer (and an int64-range Bignum) formats without
    allocating a *big.Int. This activates once go.mod consumes the
    go-ruby-format/format int64 fast path; it is inert but harmless
    against the current release.
  * formatString wraps the N operands in a single backing array
    referenced by pointer, replacing one interface box per argument
    with one allocation for the whole batch.

Isolated format path (rbgo objects, bypassing the interpreter):
  before 688 ns/op, 32 allocs/op
  after  418 ns/op, 11 allocs/op  (1.65x, once the library bump lands)

Byte-exact MRI output is unchanged (the differential/golden sprintf
tests stay green); internal/vm keeps 100% coverage, with a new
Int64Fast branch test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* deps: bump go-ruby-format + go-ruby-zlib to their perf fixes

Activates the two library-side perf fixes end-to-end in rbgo:
- go-ruby-format: math/big-free int64 fast path (format engine 1.65x;
  headline sprintf gap is VM-general per-op alloc, not the formatter).
- go-ruby-zlib: pooled flate engines via Reset (zlib roundtrip
  51554->6653 ns/op = 0.88x MRI, now faster than C zlib; byte-identical
  output, MRI interop preserved). Adds klauspost/compress (indirect).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* deps: also carry the go-ruby-prime sieve bump (avoid reverting #113)

This branch predated #113 (the go-ruby-prime segmented-sieve bump), so its
go.mod still pinned the pre-fix version. Match main's pin so merging this
PR does not regress Prime.each back to ~12.8x MRI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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