Skip to content

Meta: surpass CRuby on Rails-shaped workloads (perf roadmap A → B → C) #378

Open

Description

@linyiru

Where we are (measured 2026-09-23, Mac Studio M2 Max)

Rails 8.1 hello world through Rack::MockRequest, steady state:

config µs/request
CRuby 3.4.1 interp ~240
CRuby 3.4.1 +YJIT ~130
rubyrs interp ~1250
rubyrs +tier-2 JIT ~1350 (≈8% slower than interp)

CRuby TracePoint census per request: 1427 Ruby calls, 1654 C calls, 223 block calls, 433 allocations. So rubyrs spends ≈380 ns per event, versus ≈70 ns for CRuby.

The gap is uniform, not a few hot spots

poc/rails-spike/shape-bench.rb measures ns/op after subtracting the empty-loop cost. Selected rows:

shape rubyrs CRuby interp ×
empty while iteration (not subtracted) 38 9.5 4
0-arg call 96 16 6
yield 224 27 8
Array#each (10 elements), interp 3143 232 13
kwargs call a:, b: 370 19 20
super 170 23 7
Class#new + initialize 350 93 4
Hash#[] (String key) 85 19 4.5
Process.clock_gettime 1602 45 35
raise + rescue 42118 391 108

Plan

A — targeted fixes. Estimated 10–20% on Rails. One issue each:

B — structural interpreter work. Needed to reach CRuby-interp parity. Tracked in #384; B2 needs an ADR:

  • B1: kwargs passing without a Hash allocation
  • B2: 8-byte Copy Value (no Rc in the enum)
  • B3: per-call-site cached method + call handler (skip the do_call cascade); SymId compares instead of name-string compares on hot paths
  • B4: Proc-free yield/blocks; frame elision (ADR 0037)

C — JIT that beats YJIT. After B. Tracked in #385.

Process

  • One PR per item. Each PR includes shape-bench before/after numbers plus the Rails bench delta, and passes cargo test, ruby_spec and diff_cruby.
  • Re-run the per-request census after A to re-rank B.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions