Repository navigation
Rounds seven to ten: all thirteen AWFY benchmarks measured; List 41%, CD 35%, NBody 34% and Permute 10% faster - #216
Merged
Conversation
…se all thirteen AWFY benchmarks The first five rounds measured Bounce, Richards, Json, DeltaBlue and Towers only. A run of all thirteen on the same tree puts IronRuby at 0.87 of CRuby 4.0.9 overall and shows the worst benchmark, Permute at 1.49, among the eight that were never run; a change aimed at calls or blocks could also have made arrays, floats or closures slower without anyone seeing it. perf-measure now records the whole suite. perf-step keeps a named subset for iterating on one experiment and runs the whole suite before deciding, on the merged tree after every merge, and at least after every third experiment of a loop. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…othing after it deopts Permute's swap (`tmp = @v[i]; @v[i] = @v[j]; @v[j] = tmp`) is specialized, but its first store was logged in the thread's JitUndoLog only so that a deopt of the second store could take it back: every call took the log (a thread-static, __tls_get_addr), marked it, logged the store and released it in a finally. In the baseline profile JitUndoLog Release, get_Current and Add and __tls_get_addr are about 9% of Permute's self time. A top-level store of a method body with no loop, no self-call and no instance variable write now goes unlogged, on the condition that nothing emitted after it can deopt; the store the body ends with is then made by IndexStoreIntOrCall/IndexStoreObjOrCall, which replace an element of a plain Array that is there and hand anything else (a Hash, a frozen array, an index that grows the array or raises, another receiver) to an ordinary call of []=, which never deopts. A body where something after the store may deopt compiles again with the store logged, as before. Measured on a loaded shared machine (load 8-10 on 4 cores), so awfy.rb's 12 s columns moved by +-20%; best-of-40 iterations of harness.rb Permute 60 1, base vs new, three alternating runs: 3303/2809, 3242/2708, 3187/2855 us (10-16% faster each time). A swap micro: 96.6/70.9, 97.4/75.7, 95.9/69.1 ns per call. Queens, Towers, Sieve, Storage, List, Bounce best-of-40: within +-5%, no consistent change. Allocation unchanged (124.6 MB/iter). The undo log is gone from Permute's profile. Checks: Util/jit-matrix.rb (with new cases: a swap that grows the array, whose last index raises, on a Hash, on an Array subclass with its own []=, and a store then an ivar write on a frozen self) the same as CRuby 4.0.9, the baseline and -X:NoJIT; Util/perf/hot-shapes-matrix.rb the same as CRuby, the baseline and -X:NoJIT -X:NoOSR; Permute under -X:NoJIT -X:NoOSR verifies. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
CD's CollisionDetector#is_in_voxel, its hottest body (12.7% self, plus 11%
of all CallSite.Target time in its sites), was declined by the method JIT
("call: x/0"): `init = motion.pos_one; fin.x - init.x' reads an attr_reader
on a local that is not a parameter, and TrySample had no profile for it, so
every Float operation in the method went through a dynamic site and boxed.
TrySample now also samples a local the method assigns exactly once from
`p.a', p anything TrySample samples and a a public attr_reader on p's
sampled class: the sample is what the sampled p's instance variable holds.
It stays a profile only - ReadSelfAttr checks the receiver's class and the
method version on every read and deopts otherwise, and the value is typed
through a guard - so a wrong sample costs a deopt, never a wrong answer.
CD, interleaved fixed-iteration runs (25 iterations, steady state, us):
base ~930k-1150k, new ~615k-750k in every one of three pairs (about -33%).
Bytes per iteration: 516 MB -> 226 MB (alloc.rb). NBody, Mandelbrot,
DeltaBlue, Richards compile exactly the same methods as before (JIT verbose
diff), so they are unaffected.
Checks: jit-matrix (new case: the shape hot, then a receiver without the
readers, Integers, Bignums, the reader redefined, a singleton method, nil)
same as CRuby with JIT on and off; hot-shapes-matrix same as baseline; CD
with -X:NoJIT -X:NoOSR verifies; spec/language as baseline; IronRuby.Tests
Release fails only the known Exception_CauseRaisedInClause1.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
Json's Parser#is_white_space and #is_digit are chains of `' ' == @current`: the literal
is the receiver, which the method JIT's `v == "lit"` intrinsic did not take, so both
were screen-rejected ("StringLiteral") and ran generically - a fresh literal String and
a dynamic String#== per comparison, MutableString::Equals 7.2% of Json's self time.
String#== of a literal receiver is String#=== of that literal, which `when "lit"`
already compiles (JitRuntime.CaseString): the contents of a String v, false for nil,
true, false, an Integer, a Float or a Symbol while none responds to to_str, a deopt for
anything else. `"lit" == v` and `"lit" != v` now go there. Both intrinsics also take the
literal's characters when it is ASCII in an ASCII-compatible encoding and compare them
ordinally with a String that holds characters in an encoding where ASCII is its own
bytes (MutableString.EqualsAsciiLiteral); anything else still goes through Equals.
Json: is_white_space and is_digit specialize (no deopts); skip_white_space inclusive
9.3% -> 7.0%, read_digit 6.5% -> 5.8%; the shape alone (four comparisons) 92 -> 55 ns.
Json AWFY base/new on a loaded machine: 0.93, 0.93, 0.95 in one series, mixed (0.82 to
1.12) in two noisier ones, so unproven on time; bytes unchanged.
hot-shapes-matrix gains the shape with v of every encoding and kind and NilClass#to_str,
NilClass#== and String#== redefined in the middle: identical on CRuby, JIT, NoJIT and the
baseline; jit-matrix identical; Json NoJIT verifies; IronRuby.Tests only the known
Exception_CauseRaisedInClause1.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…assigned once from an attr read CD's hottest method, CollisionDetector#is_in_voxel, reads attributes of locals (`init = motion.pos_one; fin.x - init.x') and was declined, so its forty Float operations ran through dynamic sites and boxed every result. Measured alone against 9f4d44f on a quiet machine, all thirteen AWFY benchmarks, two runs: CD 0.632 and 0.720 of the baseline's time, geomean of the thirteen 0.973 and 0.976, no benchmark more than 5% slower in both. Bytes per CD iteration 516 MB -> 226 MB. The first iteration is not slower (1.5 s against 2.1 s). Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…unlogged in the method JIT Permute's `swap' (`tmp = @v[i]; @v[i] = @v[j]; @v[j] = tmp') was specialized, but its first store went through the thread's JitUndoLog so that a deopt in the second could take it back: about 9% of Permute's time in the log and its thread-local lookup. Measured alone against 9f4d44f on a quiet machine, five runs: Permute 0.862, 0.812, 0.856, 0.868 and 0.841 of the baseline's time. On all thirteen benchmarks (two runs) the geomean is 1.010 and 0.999. NBody and Sieve came out 3-4% slower on average; neither has a store this change applies to (NBody has no element store, Sieve's is inside a loop), and the JIT's decisions for both are the same line for line as the baseline's. Conflict: Util/jit-matrix.rb, where this branch and perf/cd both add cases; both are kept. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…SCII literals by characters Json's Parser#is_white_space and #is_digit are chains of `' ' == @current', the literal as the receiver, which the JIT's `v == "lit"' intrinsic did not take: both methods were screen-rejected and every comparison made a String and a dynamic String#== call. Measured alone against 9f4d44f on a quiet machine. Per call, three rounds: the whitespace check (four comparisons) 224, 219, 229 ns -> 96, 103, 102; the digit check (ten) 477, 463, 466 -> 159, 163, 164. On AWFY the gain is small: Json 0.984 and 0.963 of the baseline's time, geomean of the thirteen 0.999 and 0.996, no benchmark more than 5% slower in both runs. Kept on the per-operation rule; the benchmark figure is inside the run-to-run spread. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…d before the first store d027dbe's last store handed whatever its fast path could not do to a call of []= made by a site without a scope, which sees every method: on a receiver with a private or protected []= it called the method where CRuby raises NoMethodError or calls method_missing. The generic `recv[i] = x' has the method's scope; a method-JIT body has none. The unlogged form is now used only when the last store's receiver is an instance variable or an untyped local, nothing from the first unlogged store to the last runs Ruby code or assigns that local (locals, instance variables, literals, element reads and stores, local assignments), Array#[]= is the public builtin and no refinement is active. Before the first unlogged store, before anything is written, the receiver is read once and checked to be an Array itself (ExactArray, a deopt otherwise), and the last store stores into that value. On such a receiver a call of []= that sees every method is the generic call, so growth, an index that raises and a frozen array - also one another thread freezes or resizes in between - stay with the fallback. Anything else compiles the store logged as before. Checks: the coordinator's vis.rb (16 lines) and vis2.rb (5) the same as CRuby with the JIT on and with -X:NoJIT; stores.rb (63) the same as the baseline (its 3 differences from CRuby are the baseline's: two messages and an object address); the package tree's Util/jit-matrix.rb (630 lines) and this tree's (605) the same as CRuby, JIT on and -X:NoJIT; Util/perf/hot-shapes-matrix.rb the same as the baseline, JIT on and -X:NoJIT -X:NoOSR; IR_JIT_VERBOSE still says Permute's swap is specialized; Permute verifies under -X:NoJIT -X:NoOSR. Swap micro 91.3/67.6, 89.7/68.4, 91.5/66.9 ns; Permute best of 40 iterations 3114/2762, 3113/2668, 3293/2759 us (base/new, loaded machine). A first version checked the class with GetImmediateClassOf (MethodArray) and lost the whole gain. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…n Array checked before the first store The gate found that d027dbe's fallback for the last store ignored visibility: its call site has no scope, and a site without one sees every method. `@v[i] = x; @w[j] = x' with a @w whose []= is private called it where CRuby raises NoMethodError, called it instead of method_missing, and called a protected []= from an unrelated class. The author's cases and the first 63 of the gate missed it, because a swap reads the receiver first and deopts before any store. ff74487 reads the last store's receiver before the first unlogged store and deopts there unless it is an Array itself, and uses the unlogged form only where nothing in between can run Ruby code or reassign that receiver, Array#[]= is the public builtin and no refinement is active. On such a receiver a call that sees every method is the call the generic code makes. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…teral equality in twenty encodings Cases the gate wrote for round six's three changes, where the authors' own did not reach: jit-matrix: an attr write on a local assigned once from an attr read (the change that types such a local's reads types the receiver of a store too, which its case did not cover) - the leaf frozen, a writer method of its own, the writer redefined, a singleton writer, and a store followed by a call or an ivar write that fails. And the store a two-store method ends with on thirteen receivers: another Array, growth, an index too small, frozen, a Hash, a subclass, a []= that answers something else, a private one, one that raises, method_missing, nil, the first Array itself, Array#[]= redefined. The private []= case is the one that showed the fallback call ignoring visibility (fixed in ff74487); a swap, which the author's cases used, deopts on such a receiver before any store and never reaches the fallback. hot-shapes-matrix: `"lit" == v', `!=', `v == "lit"' and `when "lit"' with v in twenty encodings, each made with force_encoding and with encode, plus Strings built by replace, <<, Symbol#to_s. It reports with inspect: everything after this file's `using IDRefine' runs with Object#== refined, and the first version, written with `x == true', printed the same on every line. All three print what CRuby 4.0.9 prints with the JIT on and with -X:NoJIT -X:NoOSR (630 and 281 lines), and IR_JIT_VERBOSE shows the methods they are about specialized. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…e source's call, a case must reach its path, both column orders perf-gate asks a fourth question of every change: does a fast path make a call of its own in place of one the source makes? A site without the caller's scope sees private and protected methods and no refinements. That is how a store through a private []= succeeded in round six until the gate tried one. It also says how to tell that a differential case tests anything. Three cases written for this gate did not at first: a method the JIT had declined for another reason, a probe that deopted before the code it was meant to reach, and a report built on `==' under a refinement of Object#==. And that mspec must run from a checkout's root, or five examples fail on any build for want of default.mspec. The timing step now runs the two trees in both column orders. Which tree runs first moved Towers by 7-10% and NBody by 1-6% in four runs of four, more than the 5% the step allows; and perf-step puts all candidates of a round in one invocation, so that a column that cannot touch a benchmark shows how far it moves by itself. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…d, four rejected, one fault caught by the gate The numbers are now those of all thirteen AWFY benchmarks: IronRuby is at 0.823 of CRuby 4.0.9 overall on the merged tree (0.872 before the round, on the tree of round five), with CD from 1.17 to 0.76 and Permute from 1.49 to 1.25; the two trees against each other, in both column orders, 0.954 and 0.959. Landed: attr reads and writes on a local assigned from an attr read (CD), an unlogged element store before a method's last one (Permute), a String literal as the receiver of == (Json; a per-operation gain, inside the spread on the benchmark). Rejected, with their numbers: an identity fast path for != in generic code, nil-valued constants in the method JIT, non-generic attribute dispatchers, an inline cache for attribute reads. The gap list is re-ranked for what the eight new benchmarks and the five experiments showed: CD's red-black tree, NBody's Float boxes and the four things that keep its inner block out of the block-loop tier, Permute's own frame. "Caught by the gate" records the store through a private []= that the Permute change made possible until a case tried it, and three of the gate's own cases that tested nothing at first. Found on the way and left open: chunk_while under a redefined nil?, a[2**40] = x. micro.rb gains the round's three shapes (lit==, swap, locattr). Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
#215 went on while this round was measured: four faults from its second review (079cd93), no trampoline before a method the JIT has settled (b78ec3f, d76a40a), shared contents for one-character ASCII slices (965aac8), its own numbers and skill changes. Conflicts: Util/jit-matrix.rb and Util/perf/hot-shapes-matrix.rb, where both sides appended cases (upstream's first, then this branch's; no line of either is lost); perf-gate, where both rewrote the timing commands (upstream's absolute paths, with this branch's second run in the other column order); Util/perf/LEDGER.md, which is upstream's here and gets this round's entries again in a later commit, measured against 72c29b4. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…red one stays shared Merged with 965aac8, the comparison of a String with an ASCII literal (e4fc38a) read the String's content through _content, which is now a property that gives a one-character slice a content of its own before handing it out. Json's parser compares every character it reads with literals in is_white_space and is_digit, so each of them got that content after all: 39.5 MB allocated per Json iteration against 35.8 MB on 72c29b4, where the sharing landed. The comparison only looks at the characters, so it reads _rawContent, as Equals does for the shared case. Json is at 35.7 MB per iteration with it; CD and Permute are unchanged (226 MB against 516, and 124.6 both). Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…es whose content is shared After the merge with 965aac8 the comparison the method JIT emits for `"lit" == v' reads a slice's shared content as it is. The case reads a parser's input one character at a time, compares each in five compiled methods, and then appends to the slice, replaces it and retags it to UTF-16LE and to binary while the comparisons run again; the source and the slices after it must not change. It reports bytes and inspect: the first version printed the retagged String itself and met an old difference that has nothing to do with slices (`" ".force_encoding("UTF-16LE").inspect' is "\uDC20" here, "\x20" on CRuby, on the tree before round six too). 742 lines, the same on CRuby, with the JIT on, with -X:NoJIT -X:NoOSR, and on 72c29b4. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
… not at _rawContent 0ede8b6 kept a one-character slice's content shared by reading _rawContent in the comparison. 965aac8's rule is that new code does not read _rawContent: a shared content has no owner, and the accessors that may look at one are its own (SharedAsciiChar, which Equals uses). The comparison now asks SharedAsciiChar first and reads _content otherwise, after checking the encoding as before, so a slice retagged to an encoding where ASCII is not itself still goes to Equals. Json's allocation stays at the base's: 35.86 MB per iteration against 35.77 on 72c29b4 in one run (35.70 against 35.88 with the previous version; the figure moves by about 0.3% between invocations), where the plain merge was at 39.5. hot-shapes-matrix (742 lines, with the slice case) and jit-matrix (642) print what CRuby prints with the JIT on and off, as do the 202 lines of literals against every encoding. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…ded on top of round six, four rejected Round six landed in #215 while this round was being measured, so the round is recorded as the seventh, on top of #215's ledger, with its numbers taken again against 72c29b4. The numbers are those of all thirteen AWFY benchmarks: IronRuby at 0.80 and 0.79 of CRuby 4.0.9 in two runs of the merged tree (0.87 on the tree of round five, the first time the other eight were run). Against 72c29b4 the merged tree is at 0.944, 0.942 and 0.972 in three runs: CD 0.62-0.65, Permute 0.90-0.92, Json level or a few percent faster. Landed: attr reads and writes on a local assigned from an attr read (CD), an unlogged element store before a method's last one (Permute), a String literal as the receiver of == (Json, a per-operation gain). Rejected, with their numbers: an identity fast path for != in generic code, nil-valued constants in the method JIT, non-generic attribute dispatchers, an inline cache for attribute reads. The gap list gains NBody's Float boxes and the four things that keep its inner block out of the block-loop tier, CD's red-black tree, Permute's own frame, != as two dispatches, and a site that runs at two speeds. "Caught by the gate" records the store through a private []= that the Permute change made possible until a case tried it; the merge with round six that compiled, passed everything and allocated 10% more on Json; and three of the gate's own cases that tested nothing at first. Towers and Storage each looked slower in awfy.rb and were not: perf-gate now says how a slower line is looked at before it is believed (the JIT's decisions, bytes, profile, then separate processes taken alternately). Found on the way and left open: chunk_while under a redefined nil?, a[2**40] = x, inspect of a String with a stray byte in UTF-16LE. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
|
Caution Review failedThe pull request is closed. Walkthrough
|
`Math.sqrt(x)` in a hot method or an OSR-compiled loop declined the whole
body ("operator sqrt on Obj, Dbl": the constant Math was taken as the
operand of a binary operator), so NBody's advance block and CD's
Vector3D#magnitude-style code stayed generic and boxed every Float.
The compiler now takes `Math.sqrt(x)` and `::Math.sqrt(x)` when the
constant resolves, the way the generic code resolves it, to a module whose
public singleton `sqrt` is RubyMath.Sqrt under the refinements active
there. The constant is folded under the constant version guard and the
method kept by the global method version guard, as the inlined operators
are. The argument is an Integer or a Float (an object is speculated to be
one); JitRuntime.MathSqrt answers as RubyMath.Sqrt does (sqrt(-0.0) is
0.0, NaN is NaN) and deopts on a negative argument, so the generic call
raises Math::DomainError with its message.
Micro (best of 5, ns per iteration, 2M iterations): `s += Math.sqrt(f + i)`
in a while loop 60.8 base, 2.4 new, 44.3 CRuby; a call of a method
`Math.sqrt(@x*@x + @y*@y + @z*@z)` 127.6 base, 56.8 new, 64.7 CRuby.
jit-matrix.rb gains a Math.sqrt section (Integer, Bignum, -0.0, NaN, a
negative argument and its message, nil, a String, a Rational, a while loop
meeting a negative element and nil, a refinement, Math.sqrt redefined and
restored, Math shadowed in an enclosing module, the method removed): the
same output as CRuby with the JIT and OSR on and with -X:NoJIT -X:NoOSR,
and IR_JIT_VERBOSE shows each sp_ method specialized.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…ts downto block Gap 4 said that `permute' is not a light frame and that nobody had read why. That was inferred from RubyMethodScope::.ctor in the profile and never checked: IR_LIGHT_FRAMES=why prints "light: permute", and the method JIT rejects the method at its `downto' call. The scope is made because the block reads the outer local n1. The entry now says what round eight's first experiment measured: written as a `while' loop the method runs at CRuby's speed, so the block - a scope, a Proc and a BlockParam per non-leaf call for a run of one to six iterations - is the whole gap, and [BlockNotKept] on Integer#downto does not change it. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…lls, not its run length Gap 4 read as if the short runs (one to six iterations, under MinRun = 16) were what kept the `downto' block out of the block-loop tier. Round eight's Permute experiment ran the same block over 20.downto(0): the tier's screen takes it and the loop emitter gives up at "call: swap/2" and "operator perm on Obj, Int", because it has no general method call. Reproduced on dd2ee66 with IR_OSR_VERBOSE=1. The entry says so, and what the two routes that are left would have to keep. The experiment itself ended with nothing to commit. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…y Bounce moves by 20% The != shortcut (one dispatch for a != that reaches BasicObject#!=) was correct in its second version and is not kept: on a quiet machine no operand kind held 15% in every round, Integer showed nothing, and Integer against a Float got slower in all five rounds. Its first version lost the BasicObject#!= frame on hot sites whenever a library == runs Ruby code; the entry says how that was found and what the second version limits itself to. Bounce's iteration time wanders between 63 and 88 ms inside one process on every tree, so a 12-second awfy.rb figure lands on 64 or on 80 by where a fast stretch falls: that, not either candidate, was the 20% in this round's comparison. Also the differences from CRuby met on the way (frames of Integer#== and nested Array#==, the label of Struct#=='s frame, c_call events inside Array#==, Math.sqrt of a Complex). Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
`b = bodies[j]; b.x - c.x` in an outlined loop or block declined the loop
("call: x/0"): the attr read took only a receiver local the loop does not
write, read from its tuple slot. NBody's inner block is that shape.
In a core iterator's outlined loop (BlockLoopSite, whose every entry runs
MinRun iterations or more: ReceiverHints.LongRuns, from OsrLoopSite.LongRuns)
a local the loop writes is now read from its object slot, through the same
JitRuntime.ReadSelfAttr, which checks the receiver's class and the global
method version on every read and deopts on anything else, so the receiver
changing every iteration is fine. Not in a `while`: one that walks a linked
structure (`y = y.parent` in CD's Node#successor) runs a few iterations per
entry, and compiled it paid an entry allocation 721k times per CD iteration
(+3.3% bytes) for nothing. What reader x is comes from a profile: the
local's tuple slot when it holds a value, or, for a block's own local,
fresh on every yield, an element of the Array it is assigned from (`b = a[i]` or `b = @A[i]`, sampled elements all of one
class: JitCompiler.NoteLoopSample). The value is typed through a guard by
what the sample holds, as for the unwritten local.
Micro (best of 5, ns per iteration, 2M iterations; `b = bs[i % 5];
s += b.x * b.y`) in `n.times { }`: 60.2 base, 8.4 new, 58.9 CRuby. The
`while` form stays as it was (61 ns). CD's bytes per iteration are the
baseline's (226.1 MB base, 226.0 MB new).
block-loop-matrix.rb gains the shape in times, each and a while loop, met
by an element whose reader reads another variable, one whose x is a
method, nil, a private x, a singleton x, a String where the profile saw a
Float and the reader redefined: the same output as CRuby with OSR on and
with -X:NoJIT -X:NoOSR; IR_OSR_VERBOSE shows the block loops
specialized and the while loop declined.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…signs
`o.vx -= v` in an outlined loop or block declined the loop ("node:
MemberAssignmentExpression"), and `o.x = v` declined it when the loop
writes o ("attribute assignment to a typed local"). NBody's inner block
does six op-assigns, three on a local it loads every iteration.
`o.x op= v` (o a local) is now emitted as the read (the attr read of
EmitCall), the operator and the store EmitAttributeWrite makes, in the
order the generic code calls x, op and x=. EmitAttributeWrite takes a
receiver local the loop writes, in a core iterator's loop only (as the
read, see the commit before), from its object slot, profiled as the attr
read profiles it (its tuple slot, or NoteLoopSample's element), and holds
the receiver in a temporary before the value is evaluated. The store is
unchanged: WriteSelfAttr checks the receiver's class, the writer and
frozenness and deopts before writing, and logs what it replaces in the
undo log, so a deopt later in the iteration restores it and the generic
re-run writes once.
Micro (best of 5, ns per iteration, 2M iterations; two loads, a
subtraction and two `o.vx op= expr` per iteration): times block 182.1
base, 59.3 new, 152.2 CRuby. The while form, whose receivers the loop
writes, is declined as before.
block-loop-matrix.rb gains the shape met by a frozen element (FrozenError,
the other element's store made once), an element frozen part way through
a long run, a writer that counts its calls, a singleton writer on one
element, an element of another class, Integers leaving Int64, a while
loop and the writer redefined: the same output as CRuby with OSR on and
with -X:NoJIT -X:NoOSR, the block loops specialized under IR_OSR_VERBOSE
(the while loop declined).
block-loop, osr-array, jit, hot-shapes, ivar, ivar-stress and int matrices:
the same output as CRuby and as the baseline, on and off (int-matrix
differs only in Integer#hash values, as the baseline does).
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
`(a..b).each { }` and `(a...b).each { }` over Fixnums yielded to the block
every iteration with no block-loop tier: Range#each is not one of the
iterators BlockLoopSite outlines, though its loop is upto's exactly.
RangeOps.EachFixnum (the old StepFixnum, whose only caller passed step 1)
decides once, before the loop, on the run length: a run of MinRun or
fewer elements is the old loop, unchanged, with nothing to count; a longer
one runs from begin to the last element (end, or end - 1 for an
exclusive range; none for begin...Int32.MinValue) as Integer#upto does,
asking BlockLoopSite for the UpTo copy under the existing MinRun floor,
and stopping at Int32.MaxValue without wrapping. Endless, beginless,
Float and Bignum bounds keep their paths.
Micro (best of 5, ns per element): `(0...n).each { |i| s += i * 0.5 }`
52.8/45.0 base, 1.3/1.2 new, 38.8 CRuby. Runs of 0, 1, 2 and 4 elements (six
alternating rounds, median ns per element, base -> new): 111.0 -> 110.5,
138.2 -> 130.6, 84.5 -> 87.7, 57.9 -> 58.3, inside the spread of the
Math.sqrt commit, which does not touch the iterators.
block-loop-matrix.rb gains Range#each inclusive and exclusive, at both
ends of Int32, past Int32, into Int64, Float, endless and beginless
bounds, break and next with values, a frozen Range, a subclass with its
own each, an Integer overflowing, a nested run, and Range#each redefined
and restored: the same output as CRuby with OSR on and with -X:NoJIT
-X:NoOSR, the loops specialized under IR_OSR_VERBOSE. ruby/spec
core/range: 606 examples, 0 failures, as the baseline.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…d local, and Range#each in compiled loops Round eight's NBody experiment. NBody allocates 2.9 GB per iteration, mostly Float boxes, because the block-loop tier declines its inner block four ways. These four commits take three of them and half of the fourth: Math.sqrt(x) on a number with no call (method JIT and loop compiler), attr reads through a local the loop assigns, attr op-assign and attr writes through such a local, and Range#each over Integers as Integer#upto's outlined loop. The two attr changes apply inside core-iterator blocks only: in a `while' loop they compiled CD's Node#successor, which is entered 721k times per iteration for a few iterations each and paid an entry allocation every time (CD's bytes +3.0%), so that was withdrawn. NBody itself does not move: its inner runs are 0 to 4 iterations, under the tier's floor of 16, and entering a run is not cheap enough to lower it. No AWFY benchmark moves (geomean of the thirteen against the tree before, both column orders: 1.004 and 0.998; NBody and CD the same in separate processes taken alternately). What it buys is per operation, medians of three rounds on a quiet machine: Math.sqrt in a while loop 57 -> 2.3 ns, a method computing Math.sqrt(@x*@x + @y*@y) 88 -> 53, a long Range#each 35.5 -> 1.7 ns per element, attr op-assign in a 20-iteration times block 78 -> 64. Checked on a build of these commits against the tree before: IronRuby.Tests in Release (net10.0: 1253 tests, the one known failure on both; net11.0: all 1253 pass); ruby/spec language, core/range, core/math, core/integer, core/array and core/float, the same failing examples on both; block-loop-, osr-array-, jit-, hot-shapes- and ivar-matrix as CRuby with the tiers on and off, int-matrix as the tree before; ivar-stress; 124 lines of odd arguments and odd elements met on hot sites, as the tree before; bytes per CD iteration 226.0 MB on both; start-up not slower. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…tes and Range#each in compiled loops The round's one landed experiment moves no AWFY benchmark and is recorded as kept on the per-operation rule, with its three shapes added to micro.rb (sqrtw, rangeeach, blkattr) and to the ledger's table. Gap 2 says what is left for NBody: an entry to a short run that costs nothing. Until then the attr changes are limited to core-iterator blocks, because in `while' loops they made CD allocate 3% more. perf-gate gains the rule that a micro line which looks slower is measured in a process of its own: three lines were 15% slower in every round of a ten-shape script and the same on both trees alone. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…r runs of any length NBody spends its time in short iterator runs (each over five bodies, upto over a handful) that the block-loop tier never entered: MinRun was 16 because every entry allocated a MutableTuple and an object[] of arguments, which a handful of yields beat. NBody allocated 2.9 GB per iteration and ran at 1.1-1.2x CRuby. BlockLoopSite.Run now keeps one argument array (the block's tuple in slot 0) per site. An entry takes it with Interlocked.Exchange, allocates its own when another entry holds it (a run re-entered from another thread, or recursively), and puts it back in a finally after clearing the tuple and the arguments, so nothing a run held stays reachable and a run that ended in an exception or deopt leaves the next one starting clean. With an entry that allocates nothing, MinRun is one. Comments that said core-iterator loops run MinRun or more (LongRuns) now say why the attr-receiver shapes still pay there: their entry does not allocate. Numbers (Release net10.0, against the round-eight build, shared machine): - NBody, median of the last 30 of 60 iterations, six process pairs alternated: base 1826/1881/1818/1835/1906/1972 ms, new 1354/1300/1346/1345/1337/1430 ms (-26% to -31% in every pair). - Bytes per iteration: NBody 2892 MB -> 1364 MB, Richards 19.5 -> 13.8 MB, Towers 258 -> 102 KB, DeltaBlue -5%; CD, Storage, Bounce, List, Queens, Permute within +0.15%. - Other twelve benchmarks: geomean 0.994 and 0.950 of base in two full runs; Bounce, List, CD, Richards, Queens rerun twice more: level in the quiet run (0.993), single noisy runs up to +17% that did not repeat. Checks: block-loop-matrix (with three new short-run cases: FrozenError out of the copy, an Integer where Floats were, the Array grown between runs, four threads on one site; IR_OSR_VERBOSE shows each specialized), osr-array-matrix, hot-shapes-matrix, jit-matrix: identical to CRuby 4.0.9, to the baseline and to -X:NoJIT -X:NoOSR. IronRuby.Tests Release: only the known Exception_CauseRaisedInClause1 fails. micro.rb gets a short4 shape. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…aller's typed body CD's red-black tree was out of the method JIT: Vector2D#compare_to was rejected over its self call of compare_numbers, a three-line Float-only method the JIT itself specializes. A call of another method from a typed body was always refused (the earlier perf/jcall made real calls and needed the deopt-after-effect rule to give way; this does not call at all). Now a call on self, `self.m`, or `o.m` with `o` a local or ivar of a profiled Ruby class, whose target is a method currently specialized with a body that has no effect, no loop, no self call, no constants, no keywords and only mandatory parameters (JitCode.Inlinable), invokes that body's lambda in place of the call. The guards are the call site's: self's class is pinned by the entry (JitCode.InlinedSelfClass), an explicit receiver's class is checked (JitRuntime.GuardClass, a deopt), and the global method version covers redefinition, singletons, prepend, remove/undef, visibility changes. An explicit receiver only reaches public methods; no refinement may be active. The callee can only deopt, never raise, and the deopt restarts the caller generically, so a raise happens in the real callee frame with its own backtrace. A caller turning hot before its callee waits up to three profiling rounds (ReceiverHints.CalleeNotReady). The screen admits such calls only to methods whose body calls nothing as the declaring module sees it (or on an instance variable), since a method wrapped and declined later stays slower (the first version made Towers' allocations grow). Newly specialized: CD Vector2D#compare_to, Vector3D#squared_magnitude; DeltaBlue Dictionary#get_bucket, Strength#weakest, UnaryConstraint#choose_method; Json JsonArray#size. CD 0.69/0.95/0.95 of base in three awfy runs; micro `selfcall` 82 -> 35 ns. Bytes per iteration unchanged within 0.5% on all thirteen. Util/perf/inline-matrix.rb (19 cases, one per process) matches CRuby 4.0.9 and -X:NoJIT -X:NoOSR; hot-shapes-matrix and jit-matrix match the baseline; IronRuby.Tests passes except the known Release Exception_CauseRaisedInClause1. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
A method whose body made a Range from anything but two integer literals, `(@FIRST..(@last - 1))` or Json's `@input[@capture_start..end_]`, was never a light frame: RubyOps.CreateInclusiveRange took the frame's scope only to read its RubyContext, so IsScopeFree refused RangeExpression and every call made a RubyMethodScope. The literal now takes the context from its comparison storage, which the compiler already made for the runtime, and a Range literal is scope-free where its bounds are - except in a body with literal blocks, whose light frame makes the scope before the Proc anyway: SOM's Vector#each measured 5-7% slower per call as such a frame, so those bodies stay as they were. Range#initialize also called <=> through a dynamic site for every Range, two Integers included. MRI's range_init does not ask two Fixnums (-2**62 ... 2**62-1): with Integer#<=> redefined, CRuby 4.0 calls it for neither `(a..b)` nor `Range.new(1, 2)` and IronRuby called it for both. It now skips them as MRI does, and checks the stack before the <=> it still makes, since that runs Ruby code from a frame that may now be light with no entry check. Numbers on a loaded four-core machine (load 3-9): the micro.rb shape `rangelit` (a method returning @A[@b..e]) 144-162 -> 93-106 ns in three runs, a method returning `(@s..e)` 99 -> 54 ns (CPU-time medians of seven). Bytes per iteration: Json 35.8 MB -> 30.7 MB, the others within run-to-run variation. DeltaBlue, CD, Richards and Json wall time not separable from the noise in three awfy runs. veach4/veach100 (Vector#each, added to micro.rb) flat within +-8% noise. Checked: hot-shapes-matrix (new Range case appended: Fixnum, Int64, Bignum, Float, String and nil bounds, <=> redefined, nil answer, raise and recursion through <=>, Range.new redefined, binding, caller frames) identical to CRuby 4.0.9 with the JIT on and off, the baseline differs only in the <=> counts; jit-, block-loop-, block-scope-reuse-, raise-, full-message- and error-message-matrix as the baseline; ruby/spec core/range, core/integer and language as the baseline; IronRuby.Tests in Release: only Exception_CauseRaisedInClause1, which fails on the baseline too. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
# Conflicts: # Util/perf/micro.rb
…e's virtual slots
The commit before entered the copy for runs of any length, which made light
blocks over one to four elements (`a.each { |x| s += x }', `k.times', `map',
`any?') 1.2-2x slower than the yield loop: an entry still costs a fixed amount
that a cheap body never earns back in a short run.
Where the entry went, profiling `a.each { |x| s += x }' over one element:
MutableTuple.SetValue/GetValue (a virtual call, a switch and a ChkCastAny per
slot: four stores, two loads and a clearing pass over every slot) were about
20% of the run, about 30 ns of the 45-70 ns an entry added. The copy's Array
check (OsrArray -> GetImmediateClassOf, a weak-table lookup since $LOAD_PATH
gives an Array a singleton class) about 12 ns, the delegate and OsrLoopSite.Run
about 10 ns, the Exchange/finally and scope walk the rest.
- The block's tuple is now all object slots to a power of two (not padded with
DynamicNull), so up to sixteen slots it is a MutableTuple<object, ...>, and
Clear/Store/Load set its properties directly. Each light entry got about
40 ns cheaper (each_int k=1: 170 -> 128 ns, base 84).
- The floor is per block: the screen counts the body's method calls (operators
and attribute reads included); a body of BlockLoopSite.HeavyBody (6) or more
enters for a run of MinRun (1), a lighter one only for MinLightRun (5), the
shortest run measured no slower. map, select, any?, all?, none? keep their
old floor of 16 (MinCollectRun): their entry also grows and trims the result,
and they measured slower up to 8. BlockLoopSite.For(block, kind, run) gives
no site to a run under the block's floor; the iterators enter with Floor or
more left.
Numbers (Release net10.0 against the round-eight build, loaded machine):
- NBody, median of the last 30 of 60 iterations, six alternated pairs: base
1822/1809/1829/1797/1888/1845 ms, new 1183/1253/1218/1286/1252/1248 ms.
With a single floor of 5 instead, NBody was level (its hot loop is the inner
Range over 4, 3, 2, 1 bodies).
- Short-run table (iterator over k elements, 300k calls, two alternating
runs, k = 1..16): no cell slower in a way that repeated; light shapes below
the floor run the same code as base, at and above it 0.4-0.9x of base.
- Bytes per iteration: NBody 2892 MB -> 1364 MB, Richards 19.7 -> 14.2 MB,
others within 0.2%.
Checks: block-loop-matrix (short runs of five, frozen, retyped, resized,
threads; a heavy body over runs of 4, 3, 2, 1 with an object frozen mid-sweep,
IR_OSR_VERBOSE showing it specialized), osr-array-matrix, hot-shapes-matrix,
jit-matrix: identical to CRuby 4.0.9 and to -X:NoJIT -X:NoOSR. IronRuby.Tests
Release: only the known Exception_CauseRaisedInClause1. micro.rb gets each,
times, map and any? at k = 1, 2, 4.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…ment stays on the yield
The floor per block body had two steps: six calls or more entered the copy
for a run of one, fewer needed five. A body between the two lost on a single
element: `a.each { |x| s += x * 3 + x * 5 - x / 2 + (x & 7) }' (eight calls)
over one element took 140, 153 and 161 ns per call in the copy against 96, 99
and 107 through the yield, three alternating processes each; over two elements
the two were level, and from four on the copy won (182 against 300).
An entry costs about 45 ns more than a yield, and a call the copy types
saves 4 or 5 ns, so one iteration pays for the entry from about twelve calls
on. Floor is now 1 for twelve calls or more (NBody's inner block has about
47), 2 for six to eleven, 5 below that.
Measured, three alternating processes per cell, ns per call, base then new:
eight-call integer body over 1 element 164/111/120 vs 104/97/106, over 2
161/151/164 vs 163/165/162, over 3 223/225/230 vs 182/178/172; ten-call
attribute body over 1 137/143/205 vs 140/148/140, over 2 288/292/260 vs
222/208/184. NBody, median of the last half of 16 iterations, four alternating
processes: 1918, 1879, 1900, 1972 ms before the series, 1315, 1325, 1281,
1411 with it.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
# Conflicts: # Util/perf/micro.rb
…uld be inlined The screen let a method calling another be wrapped whenever the callee passed JitScreen.CanEverCompile, or the receiver was an instance variable. Many such callees can never be Inlinable (Richards' `append' has a while loop, an attribute write and a constant), so their callers were wrapped, profiled and declined, and a method wrapped and declined stays slower than one never wrapped: Richards was about 4% slower with nothing new compiled. JitInlineShape.IsInlinableShape now asks of the callee's syntax what JitCode.Inlinable will ask of its typed body: no loop, no assignment but to a local, no constant, yield or super, no call but an operator or an attribute read, only mandatory parameters. A call on an instance variable is no longer admitted regardless: it bought DeltaBlue's choose_method and cost seven methods wrapped and declined there, and one each in Json and CD; DeltaBlue measured the same either way (five alternating processes, medians 51.5 vs 52.1 ms). New `declined' lines against the baseline, all thirteen benchmarks: Json's HashIndexTable#hash_slot_for only (its callee string_hash is declined on the type of `s.size', which the syntax cannot see), while JsonArray#size moves from declined to specialized. Richards, List, Towers and the others: JIT decisions identical to the baseline. inline-matrix (19 cases) as CRuby and -X:NoJIT -X:NoOSR; hot-shapes and jit matrices as the baseline; IronRuby.Tests passes but the known Release Exception_CauseRaisedInClause1. micro.rb takes several shape names, as on the combined tree. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
# Conflicts: # Util/perf/micro.rb
…loops, small callees inlined, Range literals Numbers on the code of 5589688, all thirteen benchmarks: IronRuby/CRuby 0.785 (0.800 and 0.768 in the two runs before), NBody 0.78 from 1.08-1.21, CD 0.69, Json's allocation 35.9 -> 30.7 MB, NBody's 2892 -> 1364 MB. Against the tree of round eight, both column orders on a quiet machine: geomean 0.970 and 0.941, nothing slower in both. The ledger records the three experiments that landed, the versions of them that did not and why (a floor of one for every block made light short runs 1.5 to 2 times slower; a screen that admitted every call wrapped methods it then declined), what the gate caught before the merge, two gaps closed and two new ones: calling an iterator at all costs twice what it does in CRuby (`any?` six times), and DeltaBlue's `Vector#each`. perf-gate gains what that taught: a change to when a compiled path is entered is measured at the lengths the old rule kept out, a screen change by the whole specialized/rejected/screen-rejected line of every benchmark, and a probe's threads use names of their own. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
#215 gained seven commits after it was last merged: `a != b` bound as the negated builtin `==` (05a31f0), the full spec sweep as the gate's spec step, Util/perf/cputime.rb, and matrix cases. The conflicts were all two sides appending in one place: jit-matrix and hot-shapes-matrix keep both sets of cases, the ledger keeps #215's note on the sweep and this branch's "Caught by the gate" sections, and perf-gate takes #215's sweep step with the note on running mspec by hand kept after it. The ledger's gap 10 says that #215's `!=` binding has landed. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
After the merge of #215 through 9b2936f: IronRuby.Tests on net10.0 and net11.0, the differential matrices with #215's new cases, and the full five-suite spec sweep (32,285 examples, nothing that the known-failures list does not name) all as before. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
Most of DeltaBlue's 20,592 Vector#each calls per iteration run over one or two elements, so a change to how that iterator or its yield is run must be measured at those lengths too, not only on veach4 and veach100. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
[1].any? { |x| ... } cost 420-520 ns where CRuby takes 67-154: the prelude
(ruby4.rb) wrapped Enumerable's four predicates in Ruby methods taking *args
and &block, so every call, block form included, paid for a splat Array, a
Proc for the block, a call of __check_pattern_args__ and a second call of the
aliased C# method with &block. The C# block form itself walks an Array
directly.
The pattern form is now a C# overload of each of the four (Enumerable.cs), and
the prelude wrappers are gone, so the block form is one library call again.
The overload warns "given block not used" at the calling line as before, and
calls pattern === item through a library site, as MRI's rb_funcall does: a
private #=== now answers, where the wrapper raised NoMethodError. An Array is
walked directly for the pattern form too, as rb_ary_any_p does: an Array
subclass's #each is no longer called (CRuby does not call it).
Micro (Util/perf/micro.rb, ns per call, base -> new): s_any1 440/432 ->
198/193, s_any2 504/514 -> 219/228, s_any4 515/534 -> 256/259; the other
micro shapes unchanged within noise. Bytes per AWFY iteration unchanged
(no benchmark calls these). ruby/spec core/array and core/enumerable
any/all/none/one and core/hash/any pass as before; hot-shapes, jit,
block-loop, enum, enumerable2, error-message and refinement matrices print
what the baseline prints; a hot differential script (break/next/redo/return,
raise, recursion, &b, binding, lambda and Method blocks, Symbol#to_proc,
destructuring and it/_1 blocks, frozen and growing receivers, two threads,
Array#any? redefined and removed mid-run) prints what CRuby 4.0.9 prints,
with the JIT and OSR on and off. Enumerable_PredicatePattern1 is new;
Enumerable_PatternUnusedBlockWarning1 now counts the three warnings, which
the test host takes into its error sink rather than $stderr.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
A method that walks a linked list keeps its cursor in a local assigned
twice: from a parameter before the loop and from the cursor's own attr
read inside it (`xt = x; ... xt = xt.nxt`). TrySampleOfLocal only
sampled locals assigned exactly once, so the read had no profiled
receiver, EmitMethodAttrRead declined it ("call: next/0") and the whole
method stayed generic. List#is_shorter_than, List's hot method, and
CD's tree_minimum were declined for exactly this.
A local assigned more than once whose first assignment is from another
local of the method now samples to what that local samples to. It is a
profile like the rest of TrySample: the compiled read still checks the
receiver's class and the method version and deopts on anything else.
List and CD now specialize one more method each; the other eleven AWFY
benchmarks' [jit] lines are unchanged. List 74.4/74.6/76.7 ms -> 44.9/
49.0/44.2 ms (awfy.rb, base and new in the same run, three runs), and
8.16 MB -> 0.59 MB allocated per iteration. A micro of the shape
(is_shorter_than over lists of 4 and 6) 126/135/134 ns -> 84/84/100 ns.
Checks: a jit-matrix case for the shape (another class, a singleton
reader, false and an Integer in the list, the reader redefined, made
private, restored and removed), identical to CRuby with the JIT on and
off; jit-matrix and hot-shapes-matrix identical to CRuby and the
baseline; List, CD and Richards with -X:NoJIT -X:NoOSR verify;
IronRuby.Tests in Release fails only Exception_CauseRaisedInClause1, as
on the baseline.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
MyArr[1, 2].one? { |x| x } and MyArr[1, 2].one? called an Array subclass's
#each, where CRuby's rb_ary_one_p walks the Array and gives false. The block
and bare forms of Enumerable#one? now walk a RubyArray directly, as all?,
any? and none? already do: the length re-read every iteration, each element
yielded once, a break from the block returned as the result.
Checked against CRuby 4.0.9: a subclass with a raising #each (block, bare and
pattern forms), break, the receiver grown and shrunk by the block, an
exception rescued inside the block. Enumerable_PredicatePattern1 gains these
cases; IronRuby.Tests (Release) fails only Exception_CauseRaisedInClause1,
as the baseline does.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…vel deep CD's RedBlackTree#find_node (every voxel lookup and every `seen.get') stayed generic: the screen took `key.compare_to(current.key)' only of a method its own class defines, and only of a leaf, while Vector2D#compare_to calls compare_numbers; `current', walked down the tree from @root, had no sample; and `key' is a CallSign in one tree and a Vector2D in another, so a body inlining one class's compare_to deopted on every call of the other and was retired. - The screen takes a call on another object of a name some top-level class defines as an inlinable method, and such a callee may itself call, on self, a leaf (compare_to -> compare_numbers): one level, and only for a call on another object, since for self-calls it wrapped Json's HashIndexTable#add and #get, which were then declined. - TrySampleOfLocal's first-assignment rule (perf/rich) takes an instance variable too: `current = @root' samples what self's @root holds; each attr read of `current' still checks its receiver's class. - The profile records the first two Ruby classes of each argument. A call on a parameter seen with two inlines both callees under a class test (a third class deopts); if their types differ it inlines the sampled one. A body that inlined one class on a parameter and then deopts too often goes back to profiling (at most twice) instead of being retired, so a second class seen later is compiled in. The guards stay the call site's: the receiver's class where the call is, the global method version at the entry, public only, no refinement active, the callee's own pinned class and parameter types. find_node micro (lookups in a 300-key tree of Vector2D-like keys): 961/987/ 831 -> 563/458/439 ns per lookup (CRuby 1527). CD profile: RedBlackTree#get inclusive 8.8% -> 4.5%, CallSite.Target self 25.3% -> 21.6%; CD time in eight alternating processes level (medians 598 and 598 ms, spread 570-640 on a loaded machine): unproven. DeltaBlue specializes UnaryConstraint#choose_method, medians 63.3 -> 59.1 ms. Bytes per iteration within 1.2% on all thirteen. [jit] lines: only CD (+find_node) and DeltaBlue (+choose_method) change; no method newly declined. Checks: inline-matrix (31 new tree_ cases: callee or its callee redefined, subclass, singleton, private, protected, removed, refined; keys of another class, nil, Symbol, polymorphic, a third class; attr readers redefined, in a subclass, as a singleton; a Struct node, a nil key in a node, a cycle, root nil, root swapped by a thread, compare_to returning nil/Float/Bignum, a raise with its backtrace, caller, frozen tree, a 20000-deep chain, TracePoint), jit-matrix and hot-shapes-matrix identical to CRuby, -X:NoJIT -X:NoOSR and the baseline, except tree_int_key, which differs from CRuby on every tree (.NET interop answers 42.compare_to with Int32#CompareTo). IronRuby.Tests in Release fails only Exception_CauseRaisedInClause1, as on the baseline. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
A cursor walking a linked list (List's is_shorter_than) and a lookup in a binary tree of 300 keys whose compare_to calls a leaf on self (CD's find_node): the two shapes round ten's method-JIT changes are about, which had only scratch scripts. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
…nlined for two classes, any? out of the prelude Numbers on the code of a6b1c62, all thirteen benchmarks: IronRuby/CRuby 0.730 (0.750 and 0.779 in the two runs before), List 0.37-0.40 from 0.67. Against the tree before, both column orders: List 0.59 and 0.57, the other twelve inside the noise of a machine that was restarted between the rounds; the cells that were slower in both orders (Json, Bounce) are level in separate processes taken alternately. The ledger records the three changes that landed, what was tried and not kept (a yield reading the method's Proc once, a nil constant read in the method JIT, nesting the inlined call for self-calls), gaps 5, 6 and 8 closed with their measurements, where an iterator call's fixed cost goes, the table of what keeps each hot Richards method out of the method JIT, and what was found on the way (Int32.CompareTo reachable as Integer#compare_to). Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
Owner
Author
|
@coderabbitai review Generated by Claude Code |
Action not completed
|
Largo
added a commit
that referenced
this pull request
Nov 14, 2026
Round ten moved the pattern forms of all?/any?/none? into C# itself (PatternForItems), which supersedes the arrays branch's __<name>_with_pattern__ prelude helpers: Enumerable.cs and ruby4.rb take round ten's side. Initializers regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Largo
pushed a commit
that referenced
this pull request
Nov 15, 2026
One conflict: Src/Libraries/Initializers.Generated.cs, which this branch removes and master had regenerated for the pattern overloads of all?, any?, none? and one?. It stays removed: the generator writes it. Checked on the merged tree, Release net10.0: the generated source registers the same 3468 entries as master's checked-in file and is the same text line for line (but for a byte-order mark); IronRuby.Tests 1255 tests, the one known failure; nine probe files of the perf rounds print what CRuby prints. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
Stacked on #215 (the base is its branch, merged in through 9b2936f). #215 measured five Are-We-Fast-Yet benchmarks; this runs all thirteen and takes four more rounds of the same loop on what that showed. Each round is a set of experiments run side by side, one agent and one worktree each, measured alone against the unchanged build on all thirteen benchmarks, then together, then gated.
Math.sqrt, attribute reads and writes andRange#eachin compiled loops. No benchmark moves; kept on per-operation numbers.any?with a block twice as fast; CD's tree lookup compiled.Rounds eight to ten are new runtime code pushed after the PR was opened. They were added here because this session can push to one branch only; they can be split into PRs of their own if that reads better.
Numbers
IronRuby time / CRuby 4.0.9 time (Release, net10.0, 4 cores) on this branch's head, three runs:
A single cell moves by 10%, sometimes 20%, from run to run on this machine, more since the container was restarted between rounds nine and ten (Bounce's 1.73 is one such cell: it was 1.00 of the tree before in six alternating processes). On #215's tree at the start the geomean of the thirteen was 0.87, with Permute at 1.49 the worst of all and never measured, NBody 1.07-1.21, CD 1.17 and List 0.64. TruffleRuby 40.0.0 is at 0.05-0.06 on the same thirteen.
What each step did, measured tree against tree, all thirteen, one run in each column order:
Bytes allocated per iteration, #215 -> now: CD 516 MB -> 226, NBody 2892 -> 1364, Json 35.8 -> 30.7, List 8.2 -> 0.6, Richards 19.6 -> 3.2 (13.9 after round nine; the rest came with #215's
!=binding). The other eight are unchanged.Per operation (
Util/perf/micro.rb, one shape per process):lit==: a literal as the receiver of==, four comparisonsswap: two element stores in one methodlocattr: Float attr reads on locals assigned from attr readssqrtw:Math.sqrtin awhileloop, per iterationrangeeach: a 1000-elementRange#each, per elementselfcall: a method calling a small Float method on self twicerangelit: a method making a Range of two Integers to slice witheachlistwalk: two cursors walking linked liststreefind: a lookup in a binary tree of 300 keysa.any? { }over one elementWhat changed in the runtime
Round ten
xt = x; while yt; ...; xt = xt.nxtreadxt.nxtthrough a call site. Its first assignment, when that is from another local or an instance variable, now names where the sample comes from. It is a profile only: every read checks the receiver's class and the method version.List#is_shorter_thanand CD'stree_minimumcompile.key.compare_to(current.key)in CD'sfind_node: the callee is another class's method that itself calls a leaf, andkeyhas two classes in CD. The profile records the first two Ruby classes of each argument; a call on a parameter with two inlines both callees behind a class test, and a third class deopts. A body that inlined on one class and deopts too often profiles again (twice at most) instead of being retired.find_nodecompiles; CD's time does not move measurably.all?,any?,none?andone?are C# overloads, not prelude wrappers (9bbc915, 6b4e596). The prelude redefined the four as(*args, &block)wrappers for the pattern argument, so every block form paid a splat Array, a Proc and two more calls. Two differences from CRuby went with the wrappers: a private===on the pattern is now called, as CRuby does, and an Array subclass's own#eachis not.Round nine
finally. The shortest run that enters the copy is counted from the block: 1 for a body of twelve calls or more, 2 for six to eleven, 5 below that;map,select,any?,all?,none?keep 16. NBody's inner((i + 1)...n).eachruns 4, 3, 2, 1 times, which is why it never benefited before.compare_numbers(@x, other.x),self.m(a), oro.m(a)on a local whose class the profile sampled, wheremis a specialized Ruby method whose typed body has no effect, no loop, no constant and no call. The guards are the call site's own; an explicit receiver reaches only public methods; nothing is inlined where a refinement is active. The inlined body can only deopt, never raise.<=>(fc16b14), as in CRuby, where(1..n)does not run a redefinedInteger#<=>.Round eight (587fb94, 097600a, cdc1273, 5183dd8):
Math.sqrt(x)on a number without a call (a negative argument deopts, so the call raises Math::DomainError); attr reads, writes ando.x op= vthrough a local a core iterator's block assigns;Range#eachover Integers asInteger#upto's compiled loop.Round seven: attr reads and writes on a local assigned once from an attr read (c880232; CD's
is_in_voxel); an element store before a method's last one goes unlogged (d027dbe, ff74487; Permute'sswap);"lit" == vand"lit" != vcompiled (e4fc38a, 9021945).Tried and not kept
All are in
Util/perf/LEDGER.mdwith their numbers; none is in the tree.yieldinside a block reading the method's Proc once (DeltaBlue faster in three runs, slower in three); running ayield <expr>block in the block-loop tier (not built: the loop compiler has noyield, and the copy would lose a frame CRuby shows); a nil-valued constant read in the method JIT (unlocks two coldinitializemethods in Richards and nothing hot); nesting the inlined call for self-calls too (wrapped two Json methods that were then declined).a.each { |x| s += x }over one or two elements 1.5 to 2 times slower); an inlining screen that admitted every call (Richards about 4% slower); Range literals as scope-free in bodies with literal blocks.a != bbound as the receiver's==negated (Integer against Float slower in all five rounds; Faster calls, blocks and instance variables: 1.86x to 1.05x of CRuby on five AWFY benchmarks #215 has since landed its own binding for the cases that were faster, merged in here).BasicObject#!=by identity; nil-valued constants (first attempt); non-generic entry points on the attribute dispatchers; an inline cache forrecv.attrin generic code.What the gate caught before anything was merged
each,times,Range#each,mapandany?over 1, 2, 4 and 8 elements showed a fixed 100-170 ns per entry that no benchmark and no byte count could show. Sent back once; the reworked version still lost on one cell, which the three-step floor fixes.@v[i] = x; @w[j] = xcalled a private[]=through a call site without a scope. Fixed in ff74487 before the change was merged.!=shortcut dropped theBasicObject#!=frame from backtraces. Fixed, then the change was rejected on its numbers.one?on an Array subclass still called itseachafter theany?change; fixed in 6b4e596. And two benchmarks "slower in both column orders" (Json 1.11 and 1.08, Bounce 1.10 and 1.92) were level in alternating processes, with identical JIT decisions on both trees.perf-gatenow says how to tell that a case reaches its path.Tooling
perf-gategains: does a fast path make a call of its own in place of one the source makes; how a line that looks slower is examined (separate processes taken alternately, one shape per process); a change to when a compiled path is entered is measured at the lengths the old rule kept out; a screen change is judged by every benchmark's whole specialized/rejected line.Util/perf/micro.rbtakes shape names as arguments and has the shapes above pluseach,times,mapandany?over 1, 2 and 4 elements.Util/perf/inline-matrix.rb(50 cases, one per process); new cases injit-matrix,hot-shapes-matrixandblock-loop-matrix.Util/perf/LEDGER.mdhas the numbers, the re-ranked gap list, what landed and what was rejected, and for Richards a table of what keeps each hot method out of the method JIT.How it was checked
On the code of this branch's head (a6b1c62; the two commits after it are a micro script and the ledger):
Exception_CauseRaisedInClause1); net11.0, all 1254 pass.Util/ci-sweep.sh, Release net10.0, four jobs): core 23130 examples, library 6011, language 2935, command_line 175, security 34; no failing example thatUtil/spec-known-failures.txtdoes not list, none of its entries newly passing, no file without a summary line.-X:NoJIT -X:NoOSR:jit-matrix(684 lines),hot-shapes-matrix(1264),ivar-matrix(252),block-loop-matrix(130),osr-array-matrix(43),block-scope-reuse-matrix(118): no differing line.inline-matrix(50 cases, 867 lines): as CRuby but for one case that differs on every build, the base included (see "Found on the way":42.compare_to).enum-matrix,enumerable2-matrixandint-matrixprint what the tree before prints.ivar-stressandblock-scope-reuse-racepass.IR_JIT_VERBOSEorIR_OSR_VERBOSEto reach the new path. Round ten's: 170 lines of receivers and patterns for the four predicates; list walks over mixed node classes, nil, a singleton reader, redefinition, visibility, a cycle, threads; a two-class call with a second and third class, callees of differing types, an argument with an effect, a nested callee redefined, namespaced classes. All as CRuby with the tiers on and off.-e 1, least of ten: 1.31-1.38 s on both trees), and a file defining 15,000 methods in 3,000 classes loads in 2.2 s on both (the new inlining screen looks through top-level classes when a method is defined).An independent review of rounds eight and nine found no fault; it was a short pass. Round ten has not had one. CodeRabbit skips this PR because its base is not the default branch.
Not run: Windows beyond CI, several runtimes in one process.
Where to look hardest
JitStub.cs,JitCompiler.Inline.cs): re-profiling a body that deopts is a new policy (MaxReprofiles); the screen admits a call on another object when some top-level class defines an inlinable method of that name, which is a heuristic that does not see namespaced classes; the arguments are evaluated before the class test.BlockLoopSite.Run): the atomic exchange and the fallback allocation under threads and re-entry, and thefinallythat clears the tuple.upto,downtoandRange#eachthe run is compared as last minus first, one less than the element count.JitCompiler.Inline.cs): the inlined lambda is the callee's own typed body, run under the caller's guards; inlining counts as a deopt for the rule that nothing which can deopt may follow an effect.===through a library site, which sees private methods (as CRuby's rb_funcall does) and no refinements.Range#initializechecks the stack before the<=>it still makes, the only guard for recursion through<=>from a light frame.TrySampleOfLocal, keyed by name), as described in the ledger.What is left (from the ledger's gap list)
each,timesormapwith a block costs about twice what it does in CRuby for a short collection: a method with a block literal allocates 335 B per call (its scope, a Proc, a BlockParam).any?is at 2.4 of CRuby over one element, from 6.2.Found on the way, not from this work, still open
42.compare_to(1)is 1 and42.respond_to?(:compare_to)is true: .NET'sInt32.CompareTois reachable on Integer (and Float) under its Ruby-style name, where CRuby raises NoMethodError.%w[apple banana].any?(/(an)+/)leaves$~nil where CRuby sets it in the caller.Enumerable#chunk_whileloses elements oncenil?answers something truthy for an Array.a[2**40] = xraises RangeError where CRuby raises NoMemoryError."\uDC20"; CRuby prints"\x20".Math.sqrt(Complex(4, 0))is 2.0 (CRuby:(2.0+0.0i)); whereInteger#==calls the argument's==, a backtrace has noInteger#==frame.🤖 Generated with Claude Code
https://claude.ai/code/session_013PQjty6LpWT6taQu2sGkNx
Summary by CodeRabbit
all?,any?,none?, andone?, using===to compare each item with the supplied pattern.