Repository navigation
Preserve Hash state and keyword flags across callable boundaries - #242
Conversation
284km
left a comment
There was a problem hiding this comment.
Reviewed exact head 10bfcaf17eb40b5ed0b8cf9639df2b6e98f7b318 against fetched current main fdda9150d8bbdef666f5b24cc15b64f713b6e4f1, including argument evaluation, method/block binding, native Method/Proc dispatch and scope cleanup. Existing reviews, inline comments and discussion were empty; no repository AGENTS.md or CLAUDE.md was found. One new Major/P2 finding is attached: Method#to_proc must bypass an overridden Method#call.
The persistent/transient flag separation and Hash-state regression coverage are useful improvements. The committed record also keeps unmatched allocation counts and pending acceptance explicit.
Validation and limits:
- The small Method#call-override reproducer returns the original method result on independent Ruby 4.0.10 and an existing main
66a7afd0O2 binary. Current main's source retains that original wrapper; this head replaces it with ordinary publiccalldispatch. This finding is based on that current base/head source comparison and the focused reference/control check, not a claimed completed exact-head binary run. - Duplicate/dead definition, name-length/specification, namespace-name, method-write and regex-capture-write gates pass. Diff whitespace checks pass.
- Fresh isolated exact-head and current-main O2 builds were started but have not completed. No fresh runtime, full corpus, allocation-file, performance or affected-platform acceptance is claimed. A development binary with later uncommitted edits was used only for exploratory diagnosis and is excluded from exact-head acceptance evidence.
- Hosted Linux job 138845118202 succeeded. Its preserved Module record reports 195 tests / 1240 assertions, no failures/errors/skips, under the original bounds (integration source
20b2afc9010efe00641cbbda873bc7285d4666e8). macOS build and dependent coverage remain incomplete; a Linux pass does not clear the recorded Darwin/global holds.
No merge: draft status, the attached actionable finding and recorded global holds prevent it. COMMENT is used because the authenticated account owns the PR.
| | VMain when has_meth world "Object" mnm || hng_sng_has world VMain mnm -> | ||
| Cons (SExpr (ECall (mnm, Cons (ESplat (EVar "__a"), Cons (EBlockPass (EVar "__b"), Nil)))), Nil) | ||
| | _ -> Cons (SExpr (EMethod (EVar "__m_meth", "call", Cons (ESplat (EVar "__a"), Cons (EBlockPass (EVar "__b"), Nil)))), Nil)) in | ||
| let body = Cons (SExpr (EMethod (EVar "__m_meth", "call", Cons (ESplat (EVar "__a"), Cons (EBlockPass (EVar "__b"), Nil)))), Nil) in |
There was a problem hiding this comment.
[Major / P2] Preserve Method#to_proc's native dispatch when Method#call is overridden
Always generating __m_meth.call makes the resulting Proc perform ordinary Ruby dispatch on the Method object. That consults its singleton call method (or an override on Method), whereas Ruby's Method#to_proc invokes the captured method directly. For example:
def original = :original
m = method(:original)
def m.call(*) = :overridden
p m.to_proc.call # Ruby 4.0.10: :originalThe previous VMain/ECall arm, still present on current main, bypasses that override; this replacement routes it to :overridden. The same issue occurs with an override on class Method. Keep the new keyword conversion at a dedicated native Method boundary that cannot be replaced through public call, and add this regression alongside the supplied-block cases.
There was a problem hiding this comment.
Fixed in 21fbdbf. Method#to_proc now creates a private EBoundCall body that invokes the shared native Method entry helpers directly, without Ruby lookup of public Method#call. Keyword conversion remains at the native proxy boundary. Its captured Method is held in an internal environment slot that cannot be a Ruby local; the argument Array is passed directly so a positional flagged Hash is not accidentally re-splatted.
Corpus 987 adds singleton and Method-class #call overrides, proxies created before/after the override, supplied blocks, builtin/operator targets, a captured-definition snapshot, direct versus splatted Hash identity/flags, break, and original block-Proc identity. All 67 output lines match clean Ruby 4.0.10 on both evaluator and VM in the final O2 build; the separate nine supplied-block cases also match. GC-root, duplicate-definition and dead-definition gates pass. The PR stays draft while the isolated allocation-file and complete corpus/source-gate replays finish.
284km
left a comment
There was a problem hiding this comment.
Follow-up review of exact head ff6e5a4e1694e97b1c2f7a054f8e49b9c086ea09 against fetched main a6c6aec902dfa0d2cc61b4c75178acd0931fe763 and the previous reviewed head 10bfcaf1.
[Major / P2 — still open] The existing Method#to_proc dispatch finding is not fixed. The current head still generates an ordinary __m_meth.call, and the changes since the previous review do not touch that wrapper. Current main retains the direct VMain invocation arm. Rechecking the singleton-override and Method-class-override controls on independent Ruby 4.0.10 returns :original in both cases. Use a native Method invocation boundary that cannot dispatch to an override of public call, and retain both controls as regressions. I have not duplicated the inline comment or resolved the thread.
The new frame-local keyword-origin bit and repeated/escaped forwarding and bare-super regressions address important provenance cases. I inspected their argument evaluation, binding and super paths. No additional actionable finding is established by this follow-up.
Independent validation: duplicate/dead-definition, name-length/specification, namespace-name, method-write and regex-capture-write checks pass; diff whitespace checks pass. No exact-head runtime build, corpus sweep, allocation-file run or performance/platform acceptance was completed here, so those results are not claimed. Existing reported measurements remain separate from these checks. Linux build is executing, macOS build/reference coverage remains queued, and downstream coverage is incomplete. Draft state, the unresolved P2 and recorded global holds prevent merging. COMMENT is used because the authenticated account owns the PR.
284km
left a comment
There was a problem hiding this comment.
Follow-up review of exact head 21fbdbfc1e55e15a84aed737e8d8a05a76446a67, including the changes since reviewed ff6e5a4e, the current base/head dispatch paths, existing reviews and the author's response. No tracked AGENTS.md or CLAUDE.md instructions were found.
The earlier Major/P2 Method#to_proc dispatch finding is fixed: the proxy now uses private EBoundCall evaluation and shared native Method entry helpers, bypassing singleton/class overrides of public Method#call. The captured Method remains private to the proxy environment. Both override regressions, keyword/positional Hash boundaries, captured definitions, builtins, supplied blocks, break and original block-Proc identity are covered by corpus 987. I have not resolved the existing review thread or duplicated its inline comment. No remaining or new actionable finding was established.
Independent Darwin arm64 validation: corpus 987 matches all 67 output lines and exit status from clean Ruby 4.0.10 in evaluator and VM modes with GC stress period 50. Three related corpus programs (builtin reflection, Proc reflection and reassigned keyword-rest/bare super) also match in both modes: 8/8 executions total. Duplicate/dead-definition checks and diff whitespace checks pass.
These executions reuse an existing ordinary O2 binary after independently comparing all 2,412 tracked files with the exact head (zero differences), verifying pinned mgz 661a01d8 and matching the binary SHA-256 8627ed94d08bbd436d60af6899b802e3c06dc5f40d5f33cc20352bc96d7df8ed to its exact-head validation manifest. That manifest records pinned compiler 9dec2ff6; this is binary reuse, not a fresh compilation. The reference binary SHA-256 matches the recorded independent Ruby 4.0.10 build.
No complete corpus, allocation-file, performance, fresh current-main integration build or platform/resource acceptance was rerun here. Hosted Linux build and macOS gem coverage are executing, with macOS build/reference and downstream coverage incomplete; this is not solely unassigned runner queueing. No merge: the PR remains draft and recorded global merge holds remain active. COMMENT is used because the authenticated account owns the PR.
284km
left a comment
There was a problem hiding this comment.
Review of head 21fbdbfc1e55e15a84aed737e8d8a05a76446a67.
Verdict: not ready to merge. Two Major findings and one Minor finding are open. All three are new in this PR. The keyword semantics I tested are otherwise good on both engines.
Setup:
- "Head" is an O2 build from a clean checkout at this exact head (binary SHA-256
8627ed94…, the same as the author's manifest). - "Main" is an O2 build of the PR's merge base
66a7afd0. That gives a same-base comparison. - The reference is Ruby 4.0.10. "Evaluator" means
MERE_RUBY_VMunset. "VM" meansMERE_RUBY_VM=1.
Earlier finding
- [Major/P2] Method#to_proc dispatches through an overridden
Method#call: resolved. I ran the bot's repro (def m.call(*) = :overridden; m.to_proc.call) and a class-levelMethod#calloverride, plus[1].map(&m). Head matches Ruby in both modes. Main got the class-level override wrong, so head improves on main here.
New findings
1. [Major] Memory grows on every flagged-Hash copy (r2k_hash_copy). Max RSS grows linearly with the number of copies. Main stays flat. Repro (MERE_RUBY_GC_TIGHT=1, max RSS):
def g(*a) = a.size
ruby2_keywords def f(*a) = g(*a)
n = ARGV[0].to_i
i = 0; t = 0
while i < n
t += f(a: i, b: 2); i += 1
end
p t| n | main eval | head eval | main VM | head VM |
|---|---|---|---|---|
| 300,000 | 87 MB | 113 MB | 85 MB | 114 MB |
| 1,200,000 | 88 MB | 202 MB | 85 MB | 204 MB |
That is about 105 bytes per call that are never freed. The likely cause is let copied9 = map_new () in r2k_hash_copy. It runs on every copy, even when hiv_made is 0, and a dropped Mere map is not reclaimed. I inferred this cause from reading; I did not instrument it. One hint: Hash#dup on main has the same map_new pattern, and it shows the same kind of growth. This path is common: any ruby2_keywords method that splats a keyword Hash into a method without keywords. Every plain Proc or Method#call that copies a flagged splat takes it too.
2. [Major] Each copy walks the whole instance-variable table once any String, Array or Hash has an ivar. r2k_hash_copy does map_iter ivars9 over every ivar in the program whenever hiv_made > 0. Main rebuilt the Hash with mkhash and never walked the table. Repro: keep 50,000 objects with 2 ivars each, set one ivar on one String, then make 20,000 calls of the f(a: i) delegation above. Instructions retired:
| main | head | |
|---|---|---|
| evaluator, no String ivar | 5.55 G | 5.60 G |
| evaluator, one String ivar | 5.52 G | 33.66 G |
| VM, one String ivar | 4.68 G | 32.87 G |
That is about 1.4 million extra instructions per call. The cost grows with heap size, and a real program sets hiv_made easily (one ivar on any String, Array or Hash is enough). A fix could keep a small set of Hash ids that have ivars, filled by iv_put for hsh: keys. Then the walk would run only when the source Hash is in that set. The same fix would also remove the map_new from finding 1.
3. [Minor] A splat note left by a builtin makes a later block bind a positional Hash as keywords. The new run_block0x arm acts on a non-empty flagged Hash whenever arg_splat_has matches. A builtin that receives a splat (Array#push) never binds, so its note stays set. A later builtin iterator in the same body then yields the same Hash, and it binds as keywords:
G = Hash.ruby2_keywords_hash({a: 2})
def pos(*a) = a
pos(G)
[].push(*[G])
p [G].map { |a: 0| a } # Ruby 4.0.10 and main: [0]; head: [2] (both modes)Without the [].push line, head is correct, and main is wrong for a freshly made flagged Hash. So this is a narrow case. It is still worse than main for this sequence. A fix could clear slot 1 when a builtin takes its arguments, or when a builtin iterator starts yielding.
What I ran (both engines, against Ruby 4.0.10)
- Corpus 987: head matches all 67 lines and the exit status in both modes. Main differs on 28 of them.
- 61 related corpus programs (keyword, splat, forwarding, super, to_proc): all match on stdout in both modes. Program 343 differs only by a stderr warning path, and main shows the same difference.
- Keyword semantics probe, 88 cases, all match in both modes. It covers
**kw, anonymous**and...forwarding, including repeated forwarding and a positional Hash through.... It coversruby2_keywordsmethods and procs: the flag is set, cleared ondup/clone/merge/Hash[], kept byto_h, and seen throughHash.ruby2_keywords_hash?. It coverssend,public_send,method(...).call,to_proc,bind_call,define_method,method_missing, lambdas, procs,yield, zsuper and explicitsuper(with**kmutated or reassigned), andruby2_keywords/...withsuper. It covers callee mutation through**,...,send, Method, Proc and flagged splats (the caller's Hash is unchanged),**{}in eight call forms,**nil(passed anddef m(**nil)), non-Symbol keys, and keyword defaults that read other keywords. Main fails 3 of these 88 cases; head fixes all 3. - Edge probe, 69 cases. It covers notes after builtins, attribute and index setters, TracePoint,
method_missing, Fiber, Thread, Enumerator,instance_exec,define_method, manyMethod#to_procshapes,binding.local_variablesinside...(the internal__fwd~kwslot does not leak), escaped...procs, exceptions during argument evaluation, and copy state (subclass,compare_by_identity, default proc). Head fixes 10 of main's failures in the evaluator and 12 on the VM. The differences left on head are also on main: Thread arguments, TracePoint reentrancy and theTypeErrortext ofmap(&method)in both modes, plusb + handb << hin the evaluator only. The only regression is finding 3.
Instructions retired (main → head; the first four loops run 300k calls, the next two 200k, the Method loops 100k):
| Loop | Evaluator | VM |
|---|---|---|
plain f(i) |
−1.4% | −1.6% |
keyword f(a: i) |
−1.9% | −2.1% |
**h forwarding |
−2.6% | −2.5% |
block f { |x| x } |
+0.1% | +0.1% |
ruby2_keywords → keyword |
−1.1% | −1.0% |
... → keyword |
0.0% | +0.5% |
Method#call |
−1.0% | −1.1% |
method(:m).to_proc.call(i) |
+1.1% | +1.2% |
method(:m).to_proc.call(i) { 1 } |
+6.8% | +6.7% |
map(&obj.method(:m)) |
−7.0% | −6.4% |
The first six rows took 2 runs each, and the runs agreed within 0.5%. The Method rows took 1 run each. Only the block-supplied Method proxy is more than 2% slower. The PR body reports this cost, and corpus 987 shows what it pays for (bound_with_proc, lambda_block_arity, captured_yield fail on main). I accept it. As a later optimization, the marker string built per call in EBoundCall could be skipped when the block Proc needs no policy.
Memory: apart from finding 1, keyword-call loops under MERE_RUBY_GC_TIGHT=1 have the same or lower max RSS than main.
What I only read
- The full diff, the loop record, and the PR body's
test_allocationnumbers (6 → 12 MATCH, R2K 28 → 8, total atomic mismatches 956 → 936). I did not reruntest_allocation.rb, the full corpus, the VM corpus or the source gates. I rely on the author's posted runs for those (878/878 with the hash index on and off, VM 878/0 fallback, nine gates). - Merge with current main (
d03cbb83):git merge-treeis clean. Main's changes since the base (#239, #240, #246, #253, #257, #261, #264) do not toucheval_args_go,bind_params,run_block0x, the Method entry orzsuper_all. #227 (empty**) is already in the base, and the empty-**cases above match. #240 changes Hash key building, but this PR's copy uses the native dup and does not rebuild keys. #261 added the VM fallback list, so the merged tree must keep corpus 987 on the VM. I did not build the merged tree.
CI on this head: the main CI workflow is still queued. The other eight workflows passed.
| else ()) in | ||
| let oldprefix9 = oldkey9 ++ "@" in | ||
| let newprefix9 = newkey9 ++ "@" in | ||
| let copied9 = map_new () in |
There was a problem hiding this comment.
[Major] Memory grows on every copy. map_new () runs on each flagged-Hash copy, even when hiv_made is 0, and the map is never reclaimed. Under MERE_RUBY_GC_TIGHT=1, a ruby2_keywords def f(*a) = g(*a) loop (g has no keywords) grows from 113 MB at 300k calls to 202 MB at 1.2M calls. Main stays at 88 MB. Both engines show it. See finding 1 in the review body. Creating the map only inside the hiv_made branch, or better, avoiding the walk (next comment), would remove it.
There was a problem hiding this comment.
Fixed in a61735f, including the current-main merge. r2k_hash_copy no longer allocates a native scratch map. Hash ivar names live in an owner index maintained by iv_put/removal; the collector drops dead owners and compacts that table. In the reported delegated-call loop with MERE_RUBY_GC_TIGHT=1, max RSS at 300k -> 1.2M calls is 91,144,192 -> 91,111,424 bytes on evaluator and 90,849,280 -> 91,111,424 on VM. The paired main controls are 92,848,128 -> 92,880,896 and 91,750,400 -> 91,865,088 bytes. The linear copy-map growth is gone. The PR remains draft for final-head whole-file and full-corpus replays.
| let newprefix9 = newkey9 ++ "@" in | ||
| let copied9 = map_new () in | ||
| let _ = (if vec_get hiv_made 0 == 0 then () else | ||
| map_iter ivars9 (fn (key9: str) -> fn (value9: Val) -> |
There was a problem hiding this comment.
[Major] This walks every instance variable in the program on each copy once any String, Array or Hash has had an ivar. With 100,000 live object ivars and one String ivar, 20,000 delegated calls go from 5.5 G to 33.7 G instructions retired (evaluator; the VM is similar). Main rebuilt the Hash without a walk. Could the walk run only for a Hash known to have ivars, for example from a small id set filled by iv_put for hsh: keys? See finding 2.
There was a problem hiding this comment.
Fixed in a61735f. The native copy reads only the source Hash's indexed ivar names; it never walks ivars_g or allocates a per-copy map. The index contains native names only, removes deleted names, and is swept with dead Hash owners. Corpus 987 checks removed/re-added ivars across GC. For the paired 50,000 retained objects / 100,000 object ivars plus one unrelated String ivar / 20,000 delegated calls (GC_TIGHT=1), instructions are main -> final: evaluator 6,101,761,459 -> 6,131,905,024 (+0.49%); VM 6,557,154,590 -> 6,578,141,957 (+0.32%). Max RSS is 154,599,424 -> 139,034,624 and 151,355,392 -> 139,264,000 bytes. The earlier whole-world traversal multiplier is removed.
| (match vlast argvals with | ||
| | VHsh lh9 when map_has r2k_splat lh9 && map_has r2k_marks (str_of_int lh9) && (match hderef lh9 with Nil -> true | _ -> false) -> | ||
| (rev_vals (match rev_vals argvals with Cons (_, t9) -> t9 | Nil -> (Nil : Val list)), true) | ||
| | VHsh lh9 when arg_splat_has lh9 && map_has r2k_marks (str_of_int lh9) -> |
There was a problem hiding this comment.
[Minor] A note left by a builtin is still live here. [].push(*[g]) publishes slot 1, and push never binds, so nothing clears it. A later builtin iterator in the same body yields the same Hash, and this arm marks it as keywords:
G = Hash.ruby2_keywords_hash({a: 2})
def pos(*a) = a
pos(G)
[].push(*[G])
p [G].map { |a: 0| a } # Ruby and main: [0]; head: [2]Both engines show it. Clearing slot 1 when a builtin takes its arguments, or when a builtin iterator starts, would close it. See finding 3.
There was a problem hiding this comment.
Fixed in a61735f. A terminal native consumer now consumes both the splat note and its temporary keyword-origin mark; builtin iterator entry also consumes them. Cleanup occurs after public method resolution, so a real Ruby Array#push override still receives splatted keywords. Corpus 987 includes the reported push-then-map regression and that override case. All 71 output lines match clean Ruby 4.0.10 on evaluator and VM, also with GC stress 50; the GC-root, duplicate-definition and dead-definition gates pass.
284km
left a comment
There was a problem hiding this comment.
Follow-up review of exact head a61735fe90918761ab8d10244a1bfe59430331e9 against previously reviewed 21fbdbfc and fetched current main a63e47c366505074dab80db9285b8a7b3b6d051b. I read all existing reviews, inline discussions/responses, the updated description, the two corrective commits and their intervening main merge. No tracked AGENTS.md/CLAUDE.md instructions were found in main or head.
The two Major findings and the Minor stale-splat finding are addressed in the reviewed code:
r2k_hash_copyno longer allocates a native scratch map per copy. In the original reported delegated-call probe with tight GC, 300,000 -> 1,200,000 calls measured peak RSS of 89,784,320 -> 90,587,136 bytes on evaluator and 88,981,504 -> 90,144,768 bytes on VM. All four runs exit successfully and print the expected count. This independently removes the previously observed roughly 100 MB growth on that Darwin workload; it is not a full resource-acceptance claim.- Copies visit only the source Hash's indexed ivar names. The world-wide
ivarswalk is gone; removal updates the index and GC drops dead Hash owners and compacts its table. The author's updated instruction comparison is consistent with that implementation, but I did not independently repeat those hardware-instruction measurements. - Terminal native consumers and builtin iterators clear the transient splat note and origin. Cleanup is placed after Ruby method resolution, preserving an actual Array#push override. Corpus 987 covers push-then-map, override keywords, and removed/re-added ivars across GC.
The earlier Method#to_proc finding remains fixed. I found no new actionable issue in this follow-up and did not resolve any review thread or duplicate its inline findings.
Independent Darwin arm64 checks: corpus 987 matches all 71 stdout lines, stderr and exit status from clean Ruby 4.0.10 on evaluator and VM under GC stress period 50. Related keyword-rest/bare-super corpus 699 and Proc-reflection corpus 891 also match in both modes (six successful comparisons total). An initial related-reflection invocation used a nonexistent filename and is excluded; the correct corpus 891 passed. Duplicate/dead-definition, GC-root and diff-whitespace gates pass. The GC-root gate used the exact-source existing build's generated C.
Build reuse: all 2,449 tracked regular files match the fetched exact head byte for byte, all three imported mgz modules match pin 661a01d8bb68f5acd68e3192bd47f081d179c436, and the successful ordinary O2 build log uses the clean pinned compiler checkout 9dec2ff687a08433247dbdb7729bc19c8522e538. Copied binary SHA-256 61a37f2e1b22a62e366579400594992f0106bf620db0da31302999d84f2da090. This is build reuse, not a fresh compilation or current-main integration build. Initially sandboxed /usr/bin/time -l could not read kern.clockrate; those attempts completed the program but produced no RSS result. The authorized escalation succeeded, producing the measurements above. That sandbox limitation is not an interpreter failure.
I did not independently rerun final-head complete corpus, allocation-file, full upstream files or Linux/resource acceptance. The description correctly identifies the previous head's full results as historical. Actual hosted run 45540661088 fails unittest-harness on the missing unittest-vm CI-timing dependency (independently reproduced on fetched main) and fails build-linux at C API verification: capi/vendor/erb_escape.c is not the tree's file. Downstream coverage is skipped/incomplete; queued macOS work is not a pass. No merge: the PR is draft and recorded global merge holds remain active. COMMENT is used because the authenticated account owns this PR.
|
Updated to a15ffc1 with main a9e6898 integrated. The iterator-entry conflict retains native argument-origin consumption before main's Hash mapping conversion and any user to_hash callback. Final-head local acceptance is complete and posted in the description: 942/942 corpus programs with hash indexing ON and OFF; VM 942, fallback 0, differences 0; all nine source gates and record_hygiene; the header/vendor verifier and 18 CI-timing checks. The complete allocation file, run alone on each engine, improves from 8 MATCH / 68 RED to 14 MATCH / 62 RED. The before/after instruction counts, copy-loop memory controls and higher whole-file RSS are included. The disk-full interrupted corpus attempt is excluded; these corpus results come from its complete fresh rerun. I re-read all inline comments and review bodies after this push. The earlier Method dispatch, copy-map memory, ivar traversal and stale-origin fixes are retained. The PR is ready for another review; hosted checks are separate from the completed local results. Integration with the private forwarding slot in #245 remains explicitly called out in the description. |
284km
left a comment
There was a problem hiding this comment.
Follow-up review of exact head a15ffc1a8d21fdd674f2a866488387fdb56bd8d8, including the changes since reviewed a61735fe, the main merges, existing reviews and author responses. No tracked AGENTS.md/CLAUDE.md instructions are present in fetched main or head.
No remaining or new actionable finding was established. The earlier Method#to_proc dispatch, per-copy native-map leak, whole-world ivar traversal and stale-splat fixes remain in place. In the Hash-mapping integration, native iterator argument-origin consumption correctly precedes mapping conversion and its user callbacks. Source-owned ivar indexing and native captured-Method dispatch are retained. I have not resolved others' threads or repeated their inline findings.
Independent Darwin arm64 validation:
- Corpus 987: all 71 output lines, stderr and exit status match clean Ruby 4.0.10 on evaluator and VM, normally and with GC stress 50.
- Main's corpus 941 Hash-mapping regression: all 83 lines, stderr and exit status match in the same four configurations.
- Related bare-super/keyword-rest corpus 699 and Proc-reflection corpus 891 match on both engines under GC stress 50. Total: 12 successful comparisons.
- Duplicate/dead-definition and diff-whitespace gates pass. All 18 CI-timing self-tests pass; the earlier missing unittest-vm timing dependency is fixed in this tree.
Build reuse: all 2,573 tracked regular files match the fetched exact head byte for byte; all three imported mgz sources match pin 661a01d8. The existing ordinary O2 build log uses clean pinned compiler 9dec2ff6; the copied binary's SHA-256 is d57d3de05372f73f0795c31f9067d22f4fc06e710f90505dd6663a31ec308979, matching the exact-head validation manifest. The reference binary also matches that manifest. This is verified binary reuse, not a fresh build. The author's complete-corpus, allocation, instruction and RSS measurements were inspected but not independently repeated here; no full upstream-suite or affected-platform resource acceptance is claimed.
Fetched current main is d2630809; its prospective merge with this head is conflict-free, but that integration was not built or executed. Hosted core run 45581568759 still has Linux C API verification executing, macOS build/reference work queued, and downstream coverage incomplete. Queued work is not a pass, and the remaining work is not solely unassigned runner queues. Latest main core run 45576680799 has no created jobs yet. No merge: recorded hold_all_merges/new_failure_review_required remain active, including for already-reviewed candidates. The PR is now non-draft. COMMENT is used because the authenticated account owns this PR.
284km
left a comment
There was a problem hiding this comment.
Re-review of head a15ffc1a8d21fdd674f2a866488387fdb56bd8d8.
Verdict: not ready to merge yet. Both Major findings are resolved. The earlier Minor finding is only partly resolved: the same stale splat note survives other native consumers. Details below.
Setup:
- "Head" is the author's O2 build at this exact head. The tree is clean, and no
.merefile is newer than the binary. - "Main" is an O2 build of main
d5869476. For the performance loop I also ran a build ofa9e68981, the main commit merged into this head. - The reference is Ruby 4.0.10. "Evaluator" means
MERE_RUBY_VMunset. "VM" meansMERE_RUBY_VM=1.
Earlier findings
- [Major] Memory grows on every flagged-Hash copy: resolved (ran). I reran the same
ruby2_keywords def f(*a) = g(*a)loop withMERE_RUBY_GC_TIGHT=1. Max RSS from 300k to 1.2M calls: head evaluator 92.3 → 92.6 MB, head VM 90.6 → 90.8 MB. Main: 94.1 → 94.3 MB and 91.6 → 91.8 MB. The growth is gone. This loop costs about 3% more instructions than main (19.53 G vs 18.94 G in the evaluator). The PR body discloses this cost, and I accept it. - [Major] Each copy walks the whole ivar table: resolved (ran). Same setup as before: 50,000 kept objects with 2 ivars each and 20,000 delegated calls. I ran three variants: no String ivar, one String ivar, and one String ivar plus 2,000 Hashes that have ivars. Head evaluator: 5.78 G, 5.78 G, 5.78 G instructions. Main: 5.76 G, 5.78 G, 5.77 G. The VM is within 1% of main in all three. The new per-Hash name index (
hash_ivar_names) removes the walk. Corner cases of the index match Ruby in both modes: remove then re-add an ivar, a copy of a copy, anattr_accessoron a Hash subclass, and ivars kept acrossGC.start. A new Hash that reuses a dead Hash's id gets no stale ivars (200 tries). - [Minor] A splat note left by a builtin makes a later block bind a Hash as keywords: partly resolved (ran). The exact repro (
[].push(*[G])then[G].map { |a: 0| a }) now prints[0]in both modes, like Ruby. A real RubyArray#pushoverride still receives the keywords. Butprim_methodandbuiltin_iterare not the only native consumers. See new finding 1. - [Major/P2, bot] Method#to_proc dispatches through an overridden
Method#call: still resolved (ran). Singleton and class-levelcalloverrides, a block passed to the proxy, and a flagged Hash through the proxy all match Ruby in both modes.
The bot's only inline comment is that Method#to_proc finding. It was posted before its fix commit 21fbdbfc, and the fix is still in place.
New finding
1. [Minor] Other native consumers still leave the splat note set, so a later positional pass binds the Hash as keywords. Hash[], Struct.new, instance_variable_set and Kernel#p do not go through prim_method or builtin_iter. String#% has the same problem in the evaluator only. After one of them takes a flagged Hash by splat, the note in arg_notes slot 1 stays set. The note then survives unrelated calls. The keyword arm in the binder (arg_splat_has id8 ... mark_kw id8) and the run_block0x arm then treat a later positional pass of the same Hash as keywords:
def kwm(a: 0) = a
def noop = 1
g = Hash.ruby2_keywords_hash({a: 2})
Hash[*[g]] # or S.new(*[g]), o.instance_variable_set(:@x, *[g]), p(*[g])
noop
p((kwm(g) rescue $!.class)) # Ruby 4.0.10: ArgumentError; head: 2 (both modes)Inside a block, head is worse than main. Here pre is ->(g) { Hash[*[g]] }:
g = Hash.ruby2_keywords_hash({a: 2}); pre.call(g)
p proc { |a: 0| a }.call(g) # Ruby and main: 0; head: 2
p (lambda { |h, a: 0| a }.call(g) rescue $!.class) # Ruby and main: 0; head: ArgumentErrorAt the top level and in method bodies, main gets kwm(g) wrong for any fresh flagged Hash. Head fixes that in general, but not after these consumers. So this is narrow, like the earlier Minor finding: it needs a flagged Hash, an uncovered native consumer, and the same Hash passed positionally later. A fix could clear slot 1 in one place that every native method passes through after method lookup, instead of in each consumer. Another option is to clear it when the argument list that set the note has been bound or dropped.
Regression probes since the last review (all ran, both modes, against Ruby 4.0.10)
- Keyword splats, 66 cases: all match on head. These cover
**h,**nil,**{},def m(**nil), andproc { |**nil| }. They coverruby2_keywordsmethods, procs and lambdas,method(:x).to_proc,Method#call,bind_call,define_method(block and lambda bodies),send,public_send,__send__,send(:send, ...), zsuper and explicitsuper(with**kmutated or reassigned),...(repeated, with a leading argument, with a block), anonymous*and**, andmethod_missing. Main fails 4 of them; head fixes those 4. - Hash identity and state, 83 cases. Head matches Ruby in 75. The other 8 are a gap that main has too (listed below). A passed Hash is shared where Ruby shares it: positional, rest, splat,
...,send,Method#call,to_proc, procs,yield,define_methodandsuper. It is a new Hash where Ruby makes one:**hinto a positional or keyword parameter. The caller's Hash is unchanged when the callee mutates its keywords, through methods,send, Method and Proc. A flagged Hash copied to a positional argument keeps its subclass, default, default proc,compare_by_identityand ivars. It drops its singleton methods and frozen state and runs noinitialize_copy. This holds through a method, a proc,Method#callandsend. Main fails all of these copies. - Native consumers taking a flagged splat, 27 cases:
Float#round(half:),Integer(exception:),String#lines(chomp:),Structwithkeyword_init,Data.new,Time.new(in:),unpack1(offset:),Hash.new(capacity:), and block arguments evaluated after a splat. All match on head, except one that main shares (below). - 25 related corpus programs, including 987 and main's 941: all match on stdout in both modes (987 is 71 lines, 941 is 83).
- Stale-note sweep after 16 native consumers: this found new finding 1.
push,concat,merge!,update,unshift,append,insert,include?,Array(),replaceandfetchare fine.
Gaps that main has too, so they do not block this PR (worth a follow-up):
- Ruby keeps the Hash's class, default, default proc,
compare_by_identityand ivars when a lone**h(or a flagged Hash) becomes the callee's**k. Head and main both give a plain Hash. Example:def k(**k) = k; k(**MyHash.new).classisMyHashin Ruby. ruby2_keywords def w(*a) = [].push(*a); w(a: 1): Ruby unflags the pushed Hash. Head and main keep the flag.
Performance (instructions retired, ran)
A loop of 100k iterations with 8 keyword call forms (k(a: i), k(**H), mixed rest and keywords, ..., ruby2_keywords, send, Proc#call, Method#call), with MERE_RUBY_GC_TIGHT=1. Median of 3 runs, head and main alternating:
main d5869476 |
main a9e68981 |
head | |
|---|---|---|---|
| evaluator | 36.62 G | 36.65 G | 35.87 G (−2.1%) |
| VM | 39.77 G | 39.75 G | 39.01 G (−1.9%) |
The runs of each binary agreed within 0.3%. Max RSS is also lower on head (98 vs 102 MB in the evaluator).
What I only read
- The fix commits
55a1122fanda61735fe, and the conflict resolution in the mergea15ffc1a. - The author's posted runs: corpus 942/942 with hash indexing on and off, VM corpus 942 with 0 fallback, the nine source gates, record_hygiene, and
test_allocation.rbin both modes. I did not rerun any of these. - Not posted: results for
test_keyword.rb,test_call.rbandtest_hash.rb. These are the files closest to this change. Please run them in both modes and post main → head. - The PR body reports a higher whole-file max RSS for
test_allocation.rb: evaluator 458 → 558 MB, VM 467 → 697 MB. One run of max RSS can move 2× from GC timing alone. Could you remeasure withMERE_RUBY_GC_TIGHT=1, or give the median and range of 5 runs? My keyword loops show no RSS increase, but I did not run that file. git merge-tree --write-tree origin/main origin/pr242is clean. I did not build the merged tree. The #245 integration noted in the PR body is still open.
CI on this head: three workflows passed (NKF Wasm engine, Linux build dependency controls, additional gem suites). The main CI workflow and five others are still queued.
| | other -> prim_raise "TypeError" ("no implicit conversion of " ++ conv_gives_name other ++ " into String"))) | ||
|
|
||
| and prim_method = fn (recv: Val) -> fn (name: str) -> fn (args: Val list) -> | ||
| // Leaf native arguments are consumed here; they do not run a Ruby binder. |
There was a problem hiding this comment.
[Minor] Only some native consumers clear the note. prim_method and builtin_iter clear slot 1, but Hash[], Struct.new, instance_variable_set and Kernel#p do not pass through either. String#% has the same problem in the evaluator only. After Hash[*[g]] (with g flagged), the note survives unrelated calls. Then kwm(g) (with def kwm(a: 0)) returns 2 instead of raising ArgumentError, in both modes. Inside a block, proc { |a: 0| a }.call(g) gives 2 where Ruby and main give 0. Clearing the note at one point that every native method passes through after lookup would cover all of them. See new finding 1 in the review body.
There was a problem hiding this comment.
Confirmed; the PR is back in draft. The local follow-up scopes transient splat origin at the shared invocation boundaries, including exception exits, rather than adding another list of builtin-specific cleanups. Method resolution and binding retain the incoming origin; it is retired before it can affect a later positional call. I am adding all five reported native shapes, Proc/lambda cases, native keyword parsing, Ruby overrides and conversion/inspection callbacks to corpus 987.
I will post main-to-head results for the complete test_keyword.rb, test_call.rb and test_hash.rb files on both engines, and remeasure test_allocation.rb with MERE_RUBY_GC_TIGHT=1 and an explicit UNITTEST_SEED=1 (--seed=1 on both sides). The new code is local and queued for validation under the shared machine's two-heavy-run cap; the previously posted complete results still describe a15ffc1. The next push will batch the fix and its record after local checks pass.
There was a problem hiding this comment.
Fixed in c9c54d9 and 876ffec. The shared invocation scopes (ecall_args, emethod_args, invoke_val_c0, invoke_with_block) keep incoming origin through lookup/binding and consume its note and temporary keyword mark on return or exception. Conversion/inspection callbacks temporarily hide unrelated origin and restore the pending caller state, so send and Class#new keep their actual keyword arguments. This covers native consumers without extending a per-builtin list.
Corpus 987 now matches all 90 lines on evaluator and VM, normally and under GC stress 50, including all five reported consumers followed by positional method/Proc/lambda calls, exceptions, native keyword parsing, Ruby overrides and callbacks. Main's corpus 941 still matches all 83 lines in those configurations.
Requested full-file main → head results, both engines, seed 1: test_keyword 115 MATCH / 0 RED → 115 / 0; test_call 65 / 0 → 65 / 0; test_hash 297 / 1 → 297 / 1. All files COMPLETE, no new RED case IDs; the Hash RED is the existing test_replace_memory_leak timeout. Missing native test extensions invalidated the initial attempt; the posted rerun uses unchanged upstream C sources built separately against each tree's headers.
test_allocation is 8 MATCH / 68 RED → 14 / 62 on both engines, with all 76 COMPLETE under normal GC and GC_TIGHT=1, seed 1. Tight-GC process-family max RSS (KiB) is evaluator 625,408 → 668,048, VM 565,296 → 684,688. These higher whole-file peaks remain disclosed; the fresh 300k → 1.2M copy probes stay flat. Instruction counts, including matrix and supplied-block proxy costs, are in the description.
Final O2 source 876ffec: corpus --both 942/942 ON and OFF; VM 942, fallback 0, differences 0; nine source gates, record_hygiene, header/vendor verification and CI-timing self-tests pass. Complete results and the clean reference gem list are posted in the description. This is ready for re-review; queued hosted CI is not claimed as passing. The two shared-main Hash metadata/flag gaps remain follow-ups.
284km
left a comment
There was a problem hiding this comment.
Follow-up review of exact head 876ffec8bcfe4cc7c8a700e390f19349e48e42a2, including both new fix commits since a15ffc1a, fetched current main a2322f53714b851a0870dbf4869662f4cbc1371b, existing reviews, inline threads and the author's response. Neither fetched main nor head contains tracked AGENTS.md/CLAUDE.md instructions. The prescribed shared checkout is absent, so review used a fresh temporary clone.
The remaining Minor stale-origin finding is fixed. No remaining or new actionable finding was established. The shared invocation scopes retain incoming origin through lookup/binding and retire its note and temporary keyword mark on normal and exceptional exits. Conversion/inspection callbacks hide unrelated origin and restore the pending caller state, preserving send and Class#new keyword forwarding. The earlier Method#to_proc captured-target dispatch, per-copy native-map leak and whole-world ivar traversal fixes remain in place. The common invocation boundary and added callback/override regressions address the previously uncovered consumers without another builtin-specific cleanup list. Existing review threads were left untouched.
Independent Darwin arm64 validation:
- Corpus 987: all 90 lines, stderr and exit status match clean Ruby 4.0.10 on evaluator and VM, normally and with GC stress period 50. This includes all five reported native consumers, positional method/Proc/lambda calls afterward, exceptions, supplied blocks, native keywords, Ruby overrides and callback forwarding.
- Main's corpus 941: all 83 lines match in the same four configurations. Related bare-super/keyword-rest corpus 699 and Proc-reflection corpus 891 match on both engines under GC stress 50.
- The two original standalone Hash[]/Proc reproducers now print
0, matching Ruby on both engines under GC stress 50. Total: 16 successful comparisons. - Duplicate/dead-definition, name-length/specification, namespace-name, method-write, regex-capture-write and diff-whitespace checks pass. GC-root accounting passes against the verified original build's generated C and matching source. Record hygiene passes for 343 files; all 18 CI-timing self-tests pass.
Build reuse is explicit: all 2,573 tracked regular files match this exact head byte for byte; all three imported mgz sources match pin 661a01d8. The original ordinary O2 build log and clean compiler checkout identify pinned compiler 9dec2ff6. The binary was copied into the isolated clone before execution; SHA-256 d23fb8e77ebb4d053de2ab914352c4f81323ccf34b838b9f7ef13c62aea7dfbf matches the exact-head validation manifest. The clean Ruby 4.0.10 reference also matches the recorded binary hash. This is verified binary reuse, not a fresh compilation.
The requested complete upstream-file and resource reports are now supplied. I inspected their local records and independently compared the recorded case maps: test_keyword retains 115/115 passing identities, test_call 65/65, and test_hash 297/298 on both engines, with no newly failing case. The remaining Hash case is the reported existing test_replace_memory_leak timeout. These executions compare main a9e68981 with this head; I did not rerun those files. The author's full corpus, allocation-file, instruction and RSS results remain separate from this review's executions. In particular, the disclosed tight-GC allocation-file peaks increase by 6.82% on evaluator and 21.12% on VM; the isolated flat copy-loop results do not establish a general memory repair. No full upstream-suite, latest-main integration execution or affected-platform resource acceptance is claimed here.
The prospective merge with fetched main is conflict-free, but was not built or run. Core CI run 45602800954 still has Linux C API verification executing, macOS build/reference jobs unassigned with no steps, and downstream coverage incomplete. The remaining work is not solely runner queues. Latest main core run 45603817422 was inspected and is pending with zero exposed jobs; it supplies no new acceptance evidence. The recorded hold_all_merges and new_failure_review_required remain active. Already-reviewed ready PR254 was also considered; the same global hold prevents merging it, and all other open mere-ruby candidates are drafts. merelang/mere has no open PRs. No merge performed. COMMENT is used because the authenticated account owns this PR.
284km
left a comment
There was a problem hiding this comment.
Re-review of head 876ffec8bcfe4cc7c8a700e390f19349e48e42a2. New commits since my last review: c9c54d97 and 876ffec8.
Verdict: not ready to merge yet. The scoped doors fix every native consumer I tried. But the splat note (arg_notes slot 1) can still reach a later positional call in two narrow ways. Both give a result that main gets right. See new findings 1 and 2.
Setup:
- "Head" is the author's O2 build at this exact head. The tree is clean, and no
.merefile is newer than the binary. - "Main" is an O2 build of main
d5869476. - The reference is Ruby 4.0.10. "Evaluator" means
MERE_RUBY_VMunset. "VM" meansMERE_RUBY_VM=1. - "Ran" means I ran head, main and Ruby on a probe. "Read" means I only read the code or the posted results.
Earlier items
- [Minor] Natives outside
prim_methodandbuiltin_iterleft the note set: resolved for natives (ran). The previous probes now match Ruby in both modes. I also swept 26 natives that take a flagged Hash by splat:Hash[],Struct.new,instance_variable_set,p,puts,push,unshift,insert,<<,merge,update,Struct#newwithkeyword_init,Data.define(...).new,format,sprintf,Array(),Integer()raising,fetch,dig,between?,each_with_object,send,public_sendand__send__to natives, andmethod(:p).call. After each one I called an unrelated method, then passed the same Hash positionally todef kwm(a: 0), toproc { |a: 0| }and tolambda { |h, a: 0| }. I did this at block level and inside a nested block. All of these match Ruby in both modes. Main fails 22 of them in each mode. Natives that should receive the keywords still do:Struct.new(:a, *[flagged {keyword_init: true}]),Data#new,format("%{a}"),Integer(exception:),Float#round(half:),String#lines(chomp:), andsend(:round, ...). One exception: the earlier "String#% in the evaluator" case is still open. That repro was"%p" % [*[g]]. I now see that the note comes from the array literal[*[g]], not fromString#%. See new finding 1. - Missing results for
test_keyword,test_callandtest_hash: resolved (read). The PR body now has main → head on both engines with seed 1: 115/0 → 115/0, 65/0 → 65/0, and 297/1 → 297/1. Case IDs were compared, and there are no new REDs. I did not rerun these files. test_allocation.rbmax RSS: remeasured (read). The author reran it withMERE_RUBY_GC_TIGHT=1and seed 1, one run per setting. Head is still higher: evaluator 625 → 668 MB (+6.8%), VM 565 → 685 MB (+21%). The body says the child processes callGC.disablearound the measured part, so tight GC does not help there. I tried a loop of 100kruby2_keywordsdelegations underGC.disable. Head used less memory than main there (evaluator 217 vs 225 MB, VM 225 vs 233 MB). So I cannot say what drives the higher VM peak. This is disclosed and is not a finding. A note on which test case sets the VM peak would still help.- Earlier fixes still hold (ran):
- Memory per flagged-Hash copy, with tight GC, 300k → 1.2M calls: head evaluator 91.2 → 91.1 MB, head VM 90.6 → 90.8 MB. Main is 94.1 → 94.3 MB and 91.5 → 91.8 MB. There is no growth.
- Ivar index: 50,000 kept objects and 20,000 delegated calls, in three variants. Head evaluator: 5.78 G, 5.79 G and 5.78 G instructions. Main: 5.74 G, 5.74 G and 5.76 G. The VM is within 1.4% of main. The cost does not depend on how many objects have ivars.
Method#to_proc(the bot's only inline comment, posted before its fix21fbdbfc): singleton and class-levelcalloverrides, a block passed to the proxy, and a flagged Hash through the proxy all match Ruby in both modes.
New findings
1. [Minor] A splat inside an array literal still sets the note, and unrelated calls now keep it alive. EArr items -> arr_new (eval_args env world blk items) uses the call-argument evaluator. So [*[g]], [1, *[g]] and a, b = 1, *[g] set the note and the temporary keyword mark for g. No invocation door retires them, because no call took these arguments. The new non-owner branch of arg_splat_scoped then restores the note after every unrelated call. Main's binder used to drop it on the next call.
def kwm(a: 0) = a
def noop = 1
pre = ->(g) { x = [*[g]]; nil }
g = Hash.ruby2_keywords_hash({a: 2})
pre.call(g)
noop
p (kwm(g) rescue $!.class) # Ruby, main (both modes), head VM: ArgumentError; head evaluator: 2
p [1].map { pre.call(g); proc { |a: 0| a }.call(g) } # Ruby and main: [0]; head evaluator: [2]In the evaluator, the same happens when the literal is in a Hash literal ({x: [*[g]]}), in a nested Array, or in string interpolation. "%p" % [*[g]] inside a block is the shape from my last review. On the VM, [1, *[g]] and multiple assignment show the same kwm(g) → 2. In method bodies head is still better than main, which binds the Hash as keywords in all four of my shapes. A fix could retire the note after an array literal or a multiple-assignment right side, or not publish it outside a call's argument list.
2. [Minor] A callback run by a native that owns the note sees the note. own9 treats any call whose last argument is the noted Hash as the owner. Some natives keep the note while their body runs: p, print, format("%p"), and in the evaluator also Hash#fetch with a default block. Suppose one of them calls back into Ruby (inspect, to_s, or the block), and the callback passes the same Hash positionally. Then the callback's call counts as the owner and binds the Hash as keywords:
class Cb
def initialize(h) = @h = h
def kwm(a: 0) = a
def inspect = ((kwm(@h) rescue $!.class).to_s)
end
h = Hash.ruby2_keywords_hash({a: 2})
p(*[Cb.new(h), h]) # Ruby and main: ArgumentError, then {a: 2}; head (both modes): 2, then {a: 2}puts, merge, Hash[], instance_variable_set with a to_str name, and send with a to_str name are fine. This needs a flagged Hash, a native that calls back, and the same Hash passed again. So it is very narrow. A fix could retire the note when the native body starts, as prim_method does. Only the natives that forward their arguments (send, Class#new, method_missing) would keep it.
Both findings are narrow, like the earlier Minor. Both are wrong results without an error, though, and main gets them right.
Regression probes since the last review (ran, both modes, against Ruby 4.0.10)
- Control flow through the scoped doors. A custom exception with a keyword
initialize(class, message and ivar survive),throw/catch,breakout of a native iterator, non-localreturn,retry,Enumerator#next(includingy.yield(*[g])), andFiber.resume(*[g]). All match. Main fails 3 lines here. - Recursion depth. A
ruby2_keywordsmethod that recurses with*a, and one that callspushat each level, from 2,000 to 50,000 levels.SystemStackErrorstarts at the same depth as in Ruby and main. - Callbacks that must keep the caller's keywords.
sendwith ato_strmethod name,Class#newwith a keywordinitialize, with and without leading positional arguments,**objwithto_hash, andruby2_keywordsdelegation intonew. All match. - 18 call forms after a flagged splat:
yield(*a),super(*a),Proc#call,.(),[], lambdas,[]and[]=on objects, a native[],define_singleton_method,method_missing,Method#call,&->(x), andeach_slice. All match in both modes, except the three array-literal shapes in finding 1. - Earlier probes: the 66 keyword cases, the stale-note sweeps, the native keyword cases and the
Method#to_proccases all match. The Hash-state probes show only the gaps that main shares (listed in my last review). - Corpus 987 (90 lines), 941, 699 and 891 match on stdout in both modes.
- Exceptions are rethrown by message (
fail message9). That is the same pattern as the othertry_or_msgusers, and the custom exception above keeps its class and ivars.
Performance (instructions retired, ran)
Median of 3 runs, head and main alternating, with MERE_RUBY_GC_TIGHT=1. The runs of each binary agreed within 0.3%.
| Loop | Evaluator main → head | VM main → head |
|---|---|---|
| 8 keyword call forms, 100k (same file as last time) | 36.39 G → 35.80 G (−1.6%) | 39.56 G → 38.94 G (−1.6%) |
ruby2_keywords → Ruby *a, 300k (copy loop) |
18.69 G → 19.52 G (+4.4%) | 20.06 G → 20.85 G (+4.0%) |
ruby2_keywords → push, Struct#new and Hash[], 100k each |
42.75 G → 43.26 G (+1.2%) | 44.97 G → 45.46 G (+1.1%) |
Head's copy-loop count is the same as at a15ffc1a (19.53 G), so the new doors add almost nothing there. The +4% is the disclosed cost of real copies. Max RSS is lower on head in all three loops.
What I only read
- The two new commits and the loop record.
- The posted results: corpus 942/942 with hash indexing on and off, VM 942 with 0 fallback, the nine source gates, record_hygiene,
test_allocation.rb, and the three test files above. I did not rerun any full suite or the full corpus. git merge-tree --write-tree origin/main origin/pr242is clean (maina2322f53). I did not build the merged tree. The #245 integration is still open, as the body says.
CI on this head: three workflows passed (NKF Wasm engine, Linux build dependency controls, runtime load path controls). The main CI workflow and five gem-suite workflows are still queued.
| let keep9 = vec_get arg_notes 2 in | ||
| // A native conversion/inspection callback may start before its caller | ||
| // returns. It cannot inherit a splat Hash absent from its own arguments. | ||
| let own9 = (match vlast args9 with VHsh current9 -> current9 == id9 | _ -> false) in |
There was a problem hiding this comment.
[Minor] own9 is decided by the identity of the last argument. A native that keeps the note while its body runs (p, print, format("%p"), and Hash#fetch with a default block in the evaluator) can call back into Ruby. If the callback passes the same Hash positionally, its own call is treated as the owner here, and the Hash binds as keywords. Example: p(*[Cb.new(h), h]), where Cb#inspect calls kwm(@h) with def kwm(a: 0). Ruby and main raise ArgumentError inside inspect. Head returns 2 in both modes. See new finding 2 in the review body.
There was a problem hiding this comment.
The local follow-up addresses both findings and keeps this PR in draft. Value-list splats (Array literals and both multiple-assignment forms) now use a walker that shares splat conversion without publishing call origin or dropping a flagged empty Hash. Direct Ruby method entry joins the shared invocation scopes, and native block callbacks consume incoming origin; actual yield/argument-forwarding protocols keep their dedicated argument entry.
Corpus 987 now has 111 lines. Those, plus 941/699/891, match clean Ruby 4.0.10 on both engines normally and with GC stress 50, including stderr and exit status. The same focused checks also passed after integrating main ccb6895. The integration replay caught a separate missing Module#name port in the moved Method helper; that one-line correction is committed locally and will be rebuilt before final acceptance.
The RSS investigation now identifies TestAllocation::Literal#test_hash_literal (100,000 entries) as the largest child. Exact per-process highwaters on main a9e6898 vs local 3a1cd4a are 316,833,792 vs 317,046,784 bytes for that child, and 410,058,752 vs 415,334,400 for the runner. These diagnostic measurements preserve all case outcomes and are separate from final acceptance; they do not establish that the integrated resource comparison passes. I will retain and report all five alternating main/head pairs per engine with GC_TIGHT=1 and seed 1, and investigate a higher median before asking for re-review.
The final integrated build, requested upstream files, allocation comparisons and full corpus/gates are queued under the shared two-heavy-run cap. No new push or ready-for-merge claim yet; code and its record will be pushed together after checks pass.
There was a problem hiding this comment.
The local follow-up is now integrated with pinned main 85da98fb at source 8f0bd866; it is still unpushed and this PR remains draft. The moved Method helpers have been compared in full with that main, including its flag/Struct-slot changes. Fresh ordinary O2 builds pass 148 focused engine comparisons (including all 113 corpus 987 lines, normal and GC stress 50) and the argument-marker, scratch-scope and GC-mark checks.
The complete requested files still have no new failing case IDs on either engine: keyword 115 MATCH / 0 RED, call 65 / 0, Hash 297 / 1 (the same existing leak-test timeout). All 76 allocation cases complete: main 8 / 68, head 14 / 62, with the same six Proc cases fixed.
The new external-kernel resource plan has finished all 20 runs: five alternating main/head pairs per engine, GC_TIGHT=1, seed 1, no Ruby observer or source changes, every per-case result unchanged. Median runner max RSS in bytes is evaluator 415,907,840 → 418,152,448 (+0.540%), VM 413,368,320 → 415,170,560 (+0.436%). Largest-child medians are 310,902,784 → 310,837,248 and 317,046,784 → 317,095,936. The original periodically sampled family metric is retained too: evaluator 622,400 → 662,336 KiB (+6.42%), VM 670,544 → 719,264 (+7.27%). The short-lived 100,000-entry Hash-literal child explains the substantial sampling loss; I am not treating that explanation alone as acceptance of the remaining runner difference.
Fresh copy-memory, unrelated-ivar and instruction controls are queued under the shared two-heavy-run cap. A separate runner-only diagnostic using the existing native store/region counters is prepared to check frame/block retention without modifying the upstream file or allocation accounting. Full final-source corpus/gates and the single batched push follow resource assessment; there is no new ready-for-merge claim.
There was a problem hiding this comment.
An additional cross-context control caught a further regression before final corpus acceptance: Thread.new(*[h]) { |a: 0| a }.value with a flagged Hash returns 2 on Ruby and main, but 0 on local 8f0bd86; the keyword lambda form also loses its keywords. The creator's invocation scope retires origin before the scheduled Thread binds its arguments. The diagnostic stopped at that control before running any allocation file; its completion marker was not produced.
The local follow-up stores only integer provenance bits beside the Thread's existing rooted startup argument Array. It restores them after thread-begin callbacks, immediately before binding, and retires its own temporary marks on normal and exceptional completion. Corpus 987 adds delayed startup across GC, a positional creator call before the worker starts, lambda/start/fork, plain and marked rest blocks, copy metadata and the thread-begin callback. No new Ruby container or ordinary method-call work is introduced.
I preserved the exact 8f0 source and verified O2 binary/C as historical evidence, integrated main d93de08 cleanly, and committed the follow-up locally as 931a60f. Fresh main/head O2 builds and both-engine normal/stress controls are queued under the shared two-heavy-run cap. The previous 20 kernel RSS samples and all earlier results remain tied to their original source; they are not being represented as acceptance of the new source. Resource assessment and final corpus/gates are still pending. This PR remains draft and no new code push or ready-for-merge claim has been made.
There was a problem hiding this comment.
The asynchronous follow-up now passes corpus 987's full 127 output lines on evaluator and VM, normally and with GC stress 50, including stderr and exit status. This is freshly built O2 source f04b19c, integrated with pinned main d93de08. All 172 main/head focused engine comparisons and 12 argument-marker/scratch-scope/GC-mark checks pass.
Thread startup now takes its native unflagged Hash copy before queueing and saves keyword-given/empty bits independently of the creator's call. The actual supplied Proc is rooted only until Thread completion, its keyword policy is read after thread-begin callbacks immediately before binding, and the source/argument fields and temporary marks are retired. This matches the reference's thread_create_core/thread_do_start_proc structure. The regressions cover both marked and ordinary rest blocks, literal keywords, delayed startup across GC, caller mutation after creation, and late Proc marking behind a deterministic TracePoint/Queue barrier. No process-wide per-Thread map, new Val constructor or work on ordinary method calls is added.
Separate 16-shape cross-context controls retain every main-matching result on both engines and under stress. They also confirm shared-main follow-ups: lambda arity text omits the required-keyword suffix even with an ordinary positional Hash, and Fiber.yield's pending origin can affect a later positional call. Those are recorded separately, not reported as Ruby matches.
Fresh complete test_keyword/test_call/test_hash/test_allocation comparisons and the post-test retention diagnosis are queued under the shared two-heavy-run cap. The memory issue is not marked accepted; all earlier RSS samples stay tied to their original source. Full final-source kernel RSS, performance and corpus/gates remain pending. This PR remains draft, with no new push yet; the code and final records will be batched after local checks pass.
There was a problem hiding this comment.
The fixed 20-run plan has completed on local O2 source f04b19c versus pinned main d93de08, GC_TIGHT=1 and seed 1. Every run retains all 76 cases and its normal per-case results: main 8 MATCH / 68 RED, head 14 / 62 on both engines. Every remaining RED is classified; there are no unclassified cases. The two reported regressions still pass all 127 corpus 987 lines on both engines, normally and under stress50. No new push yet.
The resource hold remains open. All sampled family peaks are retained: evaluator median 610,496 to 723,776 KiB (+18.56%); VM 578,384 to 701,232 (+21.24%). Separately, OS runner max-RSS medians are 417,890,304 to 416,989,184 bytes and 411,189,248 to 415,252,480 bytes. The original time reports also contain peak memory footprint: runner medians are 409,551,664 to 407,536,504 bytes and 403,800,880 to 404,964,168 bytes. These per-process maxima are not a simultaneous family peak, and do not clear the family-RSS increase.
A separate parent-only native ownership probe preserves the keyword VM case outcomes and the allocation case outcomes on both engines. Its observations remain diagnostic, not acceptance results. The keyword VM runner increase also reproduces, and I am isolating the large keyword-compilation case and its retained versus temporary storage. No GC policy, allocation accounting, upstream tests or bounds have changed. Final performance/full-corpus acceptance remains pending; this PR stays draft.
There was a problem hiding this comment.
Fixed in ec548ff. Shared Ruby invocation entry hides native-caller origin during inspect/to_s callbacks, and the common native block callback entry consumes it. Explicit yield and actual forwarding protocols use the argument-preserving entry. This covers p, print, format("%p") and Hash#fetch's default block even when the callback passes the same Hash again; it does not rely on per-native cleanup.
Corpus 987 now has 127 matching lines on evaluator and VM, normally and under GC stress 50, including stderr and exit status. On the integrated source: full corpus 973/973 with hash indexing ON/OFF; VM 973, fallback 0, differences 0, failures 0. The complete requested upstream-file comparisons have no new REDs; source gates and record_hygiene pass. Exact MATCH/RED counts and the existing Hash timeout are retained in the description.
The repeated allocation-file diagnosis identifies the 100,000-entry Hash-literal child at 18/20 sampled family peaks. Five alternating pairs per engine retain all values: allocation runner OS max-RSS medians change -0.424% evaluator / +0.484% VM, largest child -0.341% / +0.041%; sampled family medians remain disclosed at +2.099% / -3.407%. PID attribution and kernel counters show short-child capture-stage variation; no GC tuning or metric replacement is used. The earlier material VM rise is not reproduced against integrated main 89ad241. The description and structured loop record contain the raw samples and limitations.
| let _ = vec_set arg_notes 0 empty9 in | ||
| let _ = vec_set arg_notes 2 keep9 in | ||
| if had_kw9 then map_set kwarg_marks key9 keyword9 | ||
| else if map_has kwarg_marks key9 then map_delete kwarg_marks key9 else ())) in |
There was a problem hiding this comment.
[Minor] This restore also keeps a note that no call owns. EArr items -> arr_new (eval_args ...) publishes the note for [*[g]], [1, *[g]] and a, b = 1, *[g]. No door retires it, and this branch restores it after every unrelated call. Main dropped it at the next call. So pre = ->(g) { x = [*[g]]; nil }; pre.call(g); noop; kwm(g) gives 2 in the evaluator, where Ruby and main raise ArgumentError. See new finding 1 in the review body.
There was a problem hiding this comment.
The local follow-up now passes all 113 lines of corpus 987 on evaluator and VM, normally and with GC stress 50, including stderr and exit status. Array literals and both multiple-assignment forms use a value-list walker without publishing call origin; ordinary splats retain an empty flagged Hash, while an empty keyword merge such as [**{}] contributes no element. The native inspection/default-block callback cases also pass. These are local source 9971aa83, integrated with pinned main ccb68952; they have not been pushed yet.
The requested complete files retain main's results on both engines: test_keyword 115 MATCH / 0 RED, test_call 65 / 0, test_hash 297 / 1, with no new failing case IDs. All 76 allocation cases complete, main 8 / 68 versus head 14 / 62.
The predeclared 20-run RSS comparison retained every sample. Its sampled process-family medians are evaluator 639,808 to 682,656 KiB (+6.70%) and VM 665,968 to 635,472 KiB (-4.58%), so the evaluator resource gate stopped further acceptance. I did not replace these with favorable retries.
Current-source case attribution identifies TestAllocation::Literal#test_hash_literal (100,000 entries) as the largest child and demonstrates substantial sampling loss: in the VM main run the monitor saw 132,992 KiB for that child, while the OS recorded 317,325,312 bytes. Evaluator kernel highwaters are runner 416,055,296 to 416,301,056 bytes and Hash-literal child 310,968,320 to 310,951,936; VM values are runner 408,829,952 to 415,301,632 and child 317,325,312 to 317,112,320. All instrumented per-case outcomes remain identical. These diagnostics explain why the sampled family peak is unreliable here, but one pair does not establish final resource acceptance.
A fresh five-pair comparison per engine is queued using external OS highwater counters with no Ruby observer or source changes. It retains both the kernel counters and the original sampled metric. I will assess any remaining actual increase before resuming the full corpus and final gates. The PR remains draft; no new push or ready-for-merge claim.
There was a problem hiding this comment.
Fixed in ec548ff. EArr and both multiple-assignment paths use a value-list walker that performs splat conversion without publishing call origin. Ordinary value splats retain an empty flagged Hash; empty keyword merges omit an element and evaluate conversion once.
Corpus 987 includes [*[g]], [1, *[g]], both assignment forms, nested literals/interpolation/format, and later positional method/Proc/lambda calls. Its 127 lines match clean Ruby 4.0.10 on both engines normally and with GC stress 50. The final integrated full corpus also matches 973/973 with the hash index ON/OFF and 973 on the VM, with zero fallback, differences or failures. Final head differs from tested runtime fac12e8 only in the English validation records.
284km
left a comment
There was a problem hiding this comment.
Re-review at ec548ffa.
Resolved
- Minor — array literal / multiple assignment published the keyword flag.
EArrand both multiple-assignment paths now use the value-list walker. I ran[*[g]],[1, *[g]],x, y = *[g], a laterm(*a), a Proc call with*[{}]andHash#fetch's default block against clean Ruby 4.0.10 on a build of this head: identical output on the evaluator and the VM. - Minor — a native callback saw the caller's flag. The shared invocation entry now hides the origin during inspect/to_s callbacks, and the common block-callback entry consumes it. Corpus 987 covers
p,print,format("%p")andHash#fetch. - Hold — test_allocation VM peak +21%. Against integrated main
89ad241cthe runner's OS max-RSS medians are −0.42% (evaluator) / +0.48% (VM). The earlier rise is attributed to the 100,000-entry Hash-literal child's capture-stage variation, with the raw samples in the record. Accepted.
One thing left before merge: a conflict with current main in main.mere, in the Method-call dispatch (if (str_len name == 4 && str_eq name "name") ... on your side against the "call" / "[]" / "===" arm on main). Main's side of that region changed through #333, which routes frame reads through fh_* doors (e.g. fh_self_lv_has env / fh_self_lv_get env instead of lv_has env "self" / lv_get env "self"). Please merge current main, keep the doors in any lines you carry over (tools/iv_door_check.sh and the corpus preflight from #322/#334 now run in run_corpus.sh), rerun corpus --both and the VM corpus, and post the results. I will merge once that is pushed.
|
Merged main d4414ac and resolved the Method-call conflict, retaining the shared native entry and fh_self_lv_has / fh_self_lv_get / fh_self_set in the moved body. The complete moved body matches main apart from the existing argument-origin preparation. Pushed head:
The PR description and loop record contain these new results separately from the previously accepted main89ad allocation/RSS measurements. No new RSS measurement is claimed for this main integration. |
284km
left a comment
There was a problem hiding this comment.
Re-review at 44819352. The conflict with main is resolved. The Method-call dispatch keeps the shared native entry and the fh_self_* doors, and like main the head has no direct frame-head reads or writes left (lv_get/map_get/… on "self", "__fid", etc.). The test merge with current main is clean. With corpus --both 978/978, VM 978 / 0 fallback / 0 differences, the ten source gates and corpus 987 under GC stress posted, this is ready.
#242 copies a ruby2_keywords Hash for Method#call (r2k_hash_copy) and took its instance variables from table keys "hsh:<id>@<name>", listed per Hash in hash_ivar_names. Since step 2b' a Hash's variables are in its area, so the copy came back with none. It goes through iv_k_copy_all, which also covers a Hash still in the table, and hash_ivar_names -- kept by iv_put, the sweep and remove_instance_variable for that copy alone -- is gone.
All feature findings and the allocation RSS hold were accepted by the re-review at ec548ff. This update resolves the remaining conflict with main
d4414ac2c36be3953f2ed7a98a408fd187b7c496and preserves its frame API in the shared native Method-call helper. Its complete moved body matches main apart from this PR's existing argument-origin preparation.Final PR head:
44819352cea971b0dbc60a5f5c9326df3efee974. Validated runtime:4f4694ecbfe92525ce8377630fba056125c1ec9b. The final documentation-only tip changes no runtime/test input or binary. Hosted CI is separate from these local results.Latest main integration after accepted re-review
The re-review at ec548ff accepted both Minors, the earlier Majors and the
allocation RSS explanation against main 89ad241. Those measurements remain
identified by their original runtime; they are not relabeled as new results.
Merged main
d4414ac2c36be3953f2ed7a98a408fd187b7c496into runtime4f4694ecbfe92525ce8377630fba056125c1ec9b. TheMethod-call dispatch conflict retains the private shared native entry and
main's frame doors in its moved body. The two moved self accesses now use
fh_self_lv_has / fh_self_lv_get and fh_self_set. A token
comparison of the complete moved Method-call body with main is identical
after excluding this PR's existing argument-origin preparation. No new
allocation policy or counting change is made.
Fresh ordinary O2 validation on that merged runtime:
--both: 978/978 match, hash index ON and OFF,697.076 s. The driver's iv-door and shape-statistics
preflights run unchanged.
no fallback-list mismatch, 228.629 s.
4.0.10 in evaluator and VM modes, normally and with GC stress 50. Main's
831 method-record, 832 frame-restoration and 833 VM-ivar-cache regressions
also match in those configurations: 16 engine comparisons total.
record_hygiene PASS before and after the full sweeps. Header/vendor and
CI-timing self-tests pass. No full upstream unit suite or Rails cold run.
Binary SHA-256:
3b038941f8ba89c2441d2a5c78349ee292b73bcff21432031c7b87f8decad68b.Generated C SHA-256:
bbe562ad5d4a2ed62e7a6b26affbf4360bd517f229552251a8b0c3f78b06c684.Compiler 9dec2ff6 and mgz 661a01d8 remain pinned. The reference is the same
independently built, clean Ruby 4.0.10; default/bundled gem audit and source
revision are retained above. These checks use the shared two-run cap and
serial own corpus sweeps. The final documentation-only commit preserves all
runtime/test inputs and the validated binary. Code and record share one push.
The previously accepted allocation, upstream-file, copy-memory and instruction results below retain their original main89ad/fac12 identities. They are not fresh measurements of d4414ac.
Previously accepted feature, allocation, resource and instruction results
A flagged keyword Hash converted at an ordinary callable boundary must be an independent, unflagged copy that preserves subclass, default/default_proc, identity comparison and ivars without Ruby copy hooks. Method#to_proc must invoke its captured target even if public Method#call is overridden.
Both Minors from the 876ffec re-review are corrected: array/multiple-assignment value splats no longer publish call origin, and native inspection/default-block callbacks cannot inherit their caller's transient keyword origin. Corpus 987 adds those shapes, empty-value/keyword-merge controls and asynchronous Thread startup provenance.
Previously accepted PR head
ec548ffae4d625e6f164cfc9295f7dc0336c3457changes only the English loop and structured validation record after the tested runtime commit. All runtime/test inputs and the ordinary binary are verified unchanged. Queued hosted CI is not counted as a local pass.Runtime source
fac12e8c75aac9574d9957bd1fc84c45f3b2da4bincorporates main89ad241c7cb81c8afa4dc45852b40a0ea9ee2a29. All results below identify theseordinary O2 builds. A final documentation commit does not change runtime
sources, generated C, binaries, corpus programs or upstream test inputs.
Observable behavior and review corrections
A nonempty ruby2_keywords Hash passed through a final splat to an ordinary
positional method, Proc or lambda becomes an independent, unflagged copy.
Native copying preserves subclass, default/default_proc, compare_by_identity
and ivars, bypasses Ruby copy hooks, and drops frozen/singleton state.
Marked methods and Procs preserve their required identity/flag policy.
Method#call prepares arguments at its native boundary.
The Hash ivar-name index belongs to the source owner. A copy neither walks
unrelated ivars nor allocates a per-copy scratch map. Removal and GC retire
index entries. Method#to_proc invokes its captured target through a private
bound-call expression and shared native Method helpers, including supplied
block identity and captured definitions. Public Method#call overrides cannot
intercept that invocation.
Persistent Hash flags and transient call origin have separate lifetimes.
Array literals and both multiple-assignment forms now evaluate value splats
without publishing call origin. Ordinary splats retain an empty flagged Hash;
empty keyword merges contribute no element and evaluate their conversion once.
This fixes the first Minor from the 876ffec re-review.
Shared invocation boundaries retire origin on normal and exceptional exits.
Ruby entry hides native-caller origin during inspect/to_s callbacks; native
block callbacks consume it. Explicit yield and actual forwarding protocols
use their argument-preserving entry. This fixes p, print, format("%p") and
Hash#fetch default-block callbacks, including a callback that inspects the
very same Hash as the native caller. No per-builtin cleanup list is added.
Scheduled Threads own startup provenance independently of their creator.
Copy/unflag happens before queueing, so later caller mutation cannot change
queued keywords. Startup bits accompany the existing rooted argument Array.
The original Proc stays rooted until completion and its policy is read after
thread-begin callbacks immediately before binding. Completion retires the
source, arguments and startup block. Corpus controls include deferred startup
across GC, mutation, lambdas/start/fork, marked blocks and deterministic late
marking. No new Ruby container is added for startup provenance.
No Val constructor, unused counting-only object, ObjectSpace exclusion,
upstream test edit, resource-bound change or GC-policy change is introduced.
Reference and functional comparisons
Clean Ruby 4.0.10: revision
a704b7cd95a42cc0cf5f307137bf3aac0285b915,46 default and 38 bundled gems, zero extras, Prism 1.8.2. Compiler
9dec2ff687a08433247dbdb7729bc19c8522e538; mgz661a01d8bb68f5acd68e3192bd47f081d179c436.Use
tools/ref_ruby.shto locate and validate the reference. An independentlyinstalled clean 4.0.10 can be selected with
REF_RUBY_BIN; inspectGem::Specification and never install extra gems into Gem.default_dir.
Corpus 987: 127 matching output lines on both engines, normally and with GC
stress 50, including stderr and exit status. The focused plan completes
196 engine comparisons and twelve argument-marker/scratch-scope/GC-mark
checks. It includes main's method-record and ivar-shape regressions, with
MERE_RUBY_MREC_CHECK enabled for method-record/987 controls. Separate
cross-context controls retain every main-matching row; existing required-
keyword error-text and Fiber.yield-origin gaps remain identified follow-ups.
All four complete upstream files use seed 1. No driver limit or new failing
case ID occurs; BOTH / EXTRA stay 0 / 0 throughout. The unchanged test extensions are built separately against
main, head and reference headers.
The Hash RED remains TestHashOnly#test_replace_memory_leak (timeout on both).
Six Proc rest/post/required-rest cases, with and without a supplied block,
become MATCH on both engines. All 76 allocation cases stay in the denominator.
Remaining allocation differences
All 62 remaining RED cases are classified. Groups overlap test cases.
The remaining R2K cases are marked Method/Proc calls using
*r2k_arrayand*r2k_array1, with/without a block: expected one temporary Hash, actual zero.Literal cases now complete and are not an unmeasured timeout category.
Allocation-file peak attribution and repeated measurement
The previously posted +21% VM family-RSS increase is not reproduced after
integrating current main. Keep all twenty predeclared samples: five alternating
main/head pairs per engine, unchanged file alone, MERE_RUBY_GC_TIGHT=1,
UNITTEST_SEED=1 (upstream --seed=1), no Ruby observer and no forced collection. Every sample
retains its normal-GC case outcomes. No GC tuning or metric replacement is
used to obtain these results.
The sampled family metric is retained, including evaluator +2.099%; it is
not an exact kernel family highwater. Per-process lifetime maxima must not
be added and called a simultaneous peak. OS compression and short-child
sampling contribute substantial run variation. The sub-percent runner/child
median differences are within the recorded variation, not an improvement claim.
PID-to-child-launch attribution identifies Literal#test_hash_literal's
unchanged 100,000-entry child at 18/20 observed family peaks. Two compressed
baseline samples peak in ProcCall#test_positional_splat_parameter and
MethodCall#test_required_positional_and_keyword_parameter instead. Matching
PIDs avoids a verbose-output race that can label the preceding process with
the next test's header. All twenty largest-child kernel highwaters belong
to the Hash-literal child. In the first evaluator pair, sampled parent RSS
differs by about 2 MiB and sampled child RSS by about 47 MiB, while both child
kernel highwaters are about 311 MB. The coarse sampler catches different
stages of the same short child; it cannot establish a retained-Hash leak.
Five samples per mode/tree, runner OS max RSS in bytes (none discarded):
Five sampled-family peaks in KiB, in the same order:
The tight-GC keyword-file control also no longer reproduces the old 46 MB
VM-runner difference: runner max RSS is 319,750,144 → 323,338,240 bytes on
evaluator and 454,492,160 → 455,573,504 bytes on VM. Sampled family peaks
remain 455,024 → 488,928 and 548,064 → 567,456 KiB respectively; these single
samples are disclosed, not silently substituted with runner measurements.
Normal-GC whole-file sampled-family max RSS (single runs, KiB):
Copy slopes and instruction controls
Fresh tight-GC copy controls, OS max RSS bytes at 300,000 → 1,200,000 calls:
No former per-copy map growth recurs. The evaluator grows about 4.5 MB as
calls quadruple (main about 6.1 MB); the VM head decreases slightly.
The unrelated-ivar control retains 50,000 objects with 100,000 ivars, one
String ivar and 20,000 delegated calls:
Hardware instructions retired, ordinary loops 100k/200k and targeted loops
100k; matrix is unchanged Ruby benchmark/so_matrix.rb:
Ordinary method/block loops improve. Matrix costs about 0.9%; supplied-block
Method proxy costs about 7% for captured-target dispatch and block policy /
identity. The metadata-preserving flagged-copy loop costs about 4–5%.
These correctness costs are disclosed; no work on every call exists solely
to imitate an allocation count.
Final integration and acceptance
run_corpus.sh --both: 973/973 match, hash index ON and OFF,690.780 s.
no fallback-list mismatch, 190.713 s.
record_hygiene PASS before and after. Header/vendor and CI-timing checks pass.
Nine text gates use a verified, byte-identical source archive; bracket-depth
runs against the actual generated C. Binary and source hashes are checked
throughout the final run.
a7599bfd8d729505c70f4144eecf18c656bee4cb:corpus 987 (127 lines), corpus 993 (22 lines) and fourteen related programs
match Ruby on both engines normally and under stress 50: 64 engine
comparisons. Private forwarded-argument storage and saved keyword origin
are integrated together. This is focused integration, not full Keep generic forwarded arguments in native frame storage #245 acceptance.
Earlier public 876ffec and later private d93/f04 resource results remain
historical measurements, not acceptance of this source. The former material
peak difference is not reproduced against the newly integrated baseline;
the measured sub-percent kernel changes and positive coarse-family deltas
remain disclosed above. Diagnostic binaries and forced-GC observations are
excluded from ordinary O2 acceptance.
Heavy work uses the shared machine queue, at most two Codex heavy runs.
Own corpus sweeps are serial and each allocation-file measurement runs alone.
No full upstream unit suite or Rails cold measurement is run. Code and record
share one push. Automated mere-pr-review-watch inline comments are read after
that push, and the repository owner performs the merge.
The structured validation record retains all twenty kernel samples, per-case comparisons, input hashes, focus checks and instruction counts without local paths.
Independent reference location:
/private/tmp/mere-reference-ruby-4.0.10-install/bin/ruby; revisiona704b7cd95a42cc0cf5f307137bf3aac0285b915. It was built separately from the formerly polluted rbenv installation. Its audited gem list has 46 default, 38 bundled and zero extra gems, with Prism 1.8.2.REF_RUBY_BINselects it;tools/ref_ruby.shvalidates the reference before the corpus.Record:
loop/2026-11-25-codex-allocation-keyword-copies.md.Clean reference gem list