Skip to content

Keep generic forwarded arguments in native frame storage - #245

Draft
284km wants to merge 4 commits into
mainfrom
codex-native-forwarded-arguments
Draft

284km wants to merge 4 commits into
mainfrom
codex-native-forwarded-arguments

Conversation

@284km

@284km 284km commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Generic argument forwarding (...) constructed a Ruby Array in each method frame, including calls that never forwarded it. Store these private arguments in the existing native-list form. The frame owns the immutable list, normal recycling reclaims it, captured frames retain it for their closures, and GC follows its Ruby values. Explicit splats and bare super expand it; a target's named rest still constructs its observable Ruby Array.

Use an internal parameter/slot name containing a tilde so real __fwd locals, named *__fwd parameters and Binding writes cannot collide with or publish the packet. Parser checks, VM local naming, super and parameter reflection use the same marker. No Val tag, allocation counter, ObjectSpace exclusion or ordinary-call cleanup branch is added.

Current review integration: ea0d70126e6015808e1a6391f40b9e835131555e merges main 3c58e049, including #242 and the subsequent marked-super correction. Keep the private *__fwd~args marker throughout parser, VM, reflection and synthesized Struct wrappers, while preserving main's anonymous-rest and keyword-origin handling. Bare super reapplies saved __fwd~kw provenance for native-list payloads on every call, matching main's Array path after an earlier callee consumes its transient mark.

Fresh functional validation on this integrated head (Darwin arm64, ordinary O2, CI-pinned Mere 72bb0d0980f22c067c323695815c15bc20331898, mgz 661a01d8; reference Ruby 4.0.10 at /Users/284km/.rbenv/versions/4.0.10/bin/ruby):

  • Expanded corpus 989 has 26 matching output lines in all four engine/index modes, GC stress 32. Added repeated super across GC, Struct[]'s synthesized wrapper, and implicit/explicit super from ruby2_keywords methods into a parent declaring .... Both corpus 987 and 989 report on the VM under MERE_RUBY_VM=why.
  • Focused corpora 235, 287, 343, 585, 958, 987, both 989 files, 995 and 1142: 40/40 stdout and exit-status matches; 36/40 exact stderr matches. Corpus 343 emits an extra ... at EOL, should be parenthesized? warning in all four modes. A fresh O2 main build with the same compiler/dependency pins produces byte-identical stdout/stderr/status in all four modes; Ruby stderr is empty. This inherited diagnostic difference is retained, not counted as a strict pass.
  • StrBuf-region, GC-root, duplicate/dead-definition, method/ivar-write, name-spec, namespace/name-length and regexp-capture gates pass; class-watermark checks and negative control pass. Exact generated-C bracket depth 155 / 1024; record_hygiene 343 files passes. PR-specific whitespace checks pass; the merge index also exposes main's unchanged extra EOF blank line in corpus 1165.
  • Candidate binary SHA-256 286b9dd159b29ccef6971d2eb0c0b2b74a80e7c5b6fd0810b859c4aa7dd1e57d; fresh main binary fab0b54275eb8a1449cf4a0f89748a32179def424d93e7993c9cb8a94e6c1716.

Draft: resource acceptance remains open. This follow-up does not rerun the full corpus, allocation file, performance or memory benchmark. The historical higher allocation-file and VM literal peaks below remain unresolved. Their measurements apply to the old main/compiler, not this integration. Fresh hosted CI is pending; #273's inherited header-check correction is now included through main, but that does not itself establish a passing Linux run. No resource bound is relaxed and no PR merge is proposed.

Historical O2 measurements on b659812c6831b840cdf3bcbcb467d4491a465ef7, including main d03cbb8371a10da6c974969606018eb91af60c84, with Mere 9dec2ff6. All results in the following bullets and instruction table apply to that historical head:

  • Corpus 989: all 22 output lines match clean Ruby 4.0.10 on evaluator and VM. Covers repeated captured forwarding across GC, later independent frames, Fiber, exceptions, 10,000 arguments, keywords/blocks, super, user-local collisions and reflection. The isolated empty-forwarding call creates zero Arrays, as Ruby does.
  • sh run_corpus.sh --both: 895/895 match, hash index ON and OFF. MERE_RUBY_VM=1 corpus: 895 VM / 0 fallback / 0 differences / 0 failures.
  • All nine source gates pass: GC roots, duplicate/dead definitions, method writes, name spec, namespace names, name length, regexp captures and bracket depth. record_hygiene passes before and after the sweeps.
  • Stage 10 focused native and tree checks: corpus 989, 988 and 823 each match (three inputs, zero refusals/differences/failures); clean reference Ruby is on PATH.
  • Entire ruby/test_allocation.rb, measured alone, evaluator then VM: 8 MATCH / 68 RED → 8 MATCH / 68 RED in both modes. All 76 cases COMPLETE, no driver limit; main's literal parser fix removes the previous two timeouts. Whole-case counts still differ because other assertions in the same cases remain RED.
  • Atomic differences, both engines: excess Arrays 218 → 102, missing CRuby Arrays 198 → 222, excess Hashes 504 → 504, ruby2_keywords Hashes 28 → 28, other missing Hashes 8 → 8; total 956 → 864. The extra 24 missing-Array assertions concern CRuby-only concatenation/splat temporaries previously masked by our unwanted forwarding Array. No dummy Array replaces it.
  • Allocation-file process-family max RSS (KiB), main → head: evaluator 531,840 → 662,912; VM 514,224 → 679,104. These higher peaks are reported as a limitation, without a memory-improvement claim.
  • Additional large-program max RSS, bytes, corpus 988 (100,000-element Array and Hash literals), main → head: evaluator 325,697,536 → 325,713,920; VM 668,549,120 → 736,264,192. Matrix max RSS is evaluator 90,144,768 → 90,144,768, VM 91,291,648 → 91,324,416. The VM literal and whole allocation-file peaks increase even though the matrix stays stable.
  • All 76 cases and existing budgets/exclusions are retained. One corpus sweep at a time; no full unit suite or Rails cold measurement.

Hardware instructions retired, main → head (100k and 200k method/block loops; unchanged Ruby benchmark/so_matrix.rb):

Workload Evaluator VM
method_call.rb 3,683,619,538 → 3,686,111,202 (+0.07%) 3,957,360,123 → 3,961,439,580 (+0.10%)
method_call_200k.rb 6,417,138,436 → 6,418,489,591 (+0.02%) 7,001,762,190 → 7,000,149,771 (-0.02%)
block_call.rb 4,491,432,271 → 4,493,384,939 (+0.04%) 5,327,192,470 → 5,333,970,712 (+0.13%)
block_call_200k.rb 8,066,461,030 → 8,064,740,588 (-0.02%) 9,738,780,279 → 9,742,290,933 (+0.04%)
so_matrix.rb 199,145,357,044 → 199,171,383,031 (+0.01%) 213,205,582,546 → 213,204,636,492 (-0.00%)
forwarded_call.rb 5,591,180,369 → 5,361,561,926 (-4.11%) 6,040,780,743 → 6,021,307,523 (-0.32%)
forwarded_keyword.rb 6,238,162,795 → 6,193,336,627 (-0.72%) 7,034,462,921 → 7,005,992,308 (-0.40%)

Forwarding loops reduce instructions; ordinary workloads include small increases shown above. The extra literal-program instructions are evaluator 7,247,024,978 → 7,285,131,374 (+0.53%), VM 88,502,687,864 → 88,492,361,758 (-0.01%).

This removes actual excess forwarding Arrays. Anonymous rest and keyword packets are separate work. Missing CRuby-only internal concatenation/splat Arrays, empty-merger Hashes and unobservable marked-method/Proc copies remain explicitly not matched. Do not manufacture unused Ruby objects solely to match counts.

Integration with #242 is now functionally implemented in ea0d7012 and validated with both corpus 987 and the expanded corpus 989 above. Saved keyword provenance and the private native slot are combined; historical allocation/resource figures are not relabeled as measurements of the combined implementation.

Historical measurement reference: /private/tmp/mere-reference-ruby-4.0.10-install/bin/ruby, built from /private/tmp/mere-reference-ruby-4.0.10 revision a704b7cd95a42cc0cf5f307137bf3aac0285b915. Fresh audit: 46 default and 38 bundled gems, zero extras, Prism 1.8.2. No gems were installed into Gem.default_dir. Compiler 9dec2ff687a08433247dbdb7729bc19c8522e538, mgz 661a01d8bb68f5acd68e3192bd47f081d179c436. The complete clean-reference gem list follows.

Record: loop/2026-11-25-codex-native-forwarded-arguments.md.

Clean reference gem list
abbrev (0.1.2)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.0.1)
bundler (default: 4.0.20)
csv (3.3.5)
date (default: 3.5.1)
debug (1.11.1)
delegate (default: 0.6.1)
did_you_mean (default: 2.0.0)
digest (default: 3.2.1)
drb (2.2.3)
english (default: 0.8.1)
erb (default: 6.0.7)
error_highlight (default: 0.7.2)
etc (default: 1.4.6)
fcntl (default: 1.3.0)
fiddle (1.1.8)
fileutils (default: 1.8.0)
find (default: 0.2.0)
forwardable (default: 1.4.0)
getoptlong (0.2.1)
io-console (default: 0.8.2)
io-nonblock (default: 0.3.2)
io-wait (default: 0.4.0)
ipaddr (default: 1.2.8)
irb (1.16.0)
json (default: 2.18.3)
logger (1.7.0)
matrix (0.4.3)
minitest (6.0.0)
mutex_m (0.3.0)
net-ftp (0.3.9)
net-http (default: 0.9.1)
net-imap (0.6.4.1)
net-pop (0.1.2)
net-protocol (default: 0.2.2)
net-smtp (0.5.1)
nkf (0.2.0)
observer (0.1.2)
open-uri (default: 0.5.0)
open3 (default: 0.2.1)
openssl (default: 4.0.2)
optparse (default: 0.8.1)
ostruct (0.6.3)
power_assert (3.0.1)
pp (default: 0.6.3)
prettyprint (default: 0.2.0)
prime (0.1.4)
prism (default: 1.8.2)
pstore (0.2.1)
psych (default: 5.3.1)
racc (1.8.1)
rake (13.3.1)
rbs (3.10.0)
rdoc (7.0.4)
readline (0.0.4)
reline (0.6.3)
repl_type_completor (0.1.12)
resolv (default: 0.7.2)
resolv-replace (0.1.1)
rexml (3.4.4)
rinda (0.2.0)
rss (0.3.2)
ruby2_keywords (default: 0.0.5)
securerandom (default: 0.4.1)
shellwords (default: 0.2.2)
singleton (default: 0.3.0)
stringio (default: 3.2.0)
strscan (default: 3.1.6)
syntax_suggest (default: 2.0.3)
syslog (0.3.0)
tempfile (default: 0.3.1)
test-unit (3.7.5)
time (default: 0.4.2)
timeout (default: 0.6.0)
tmpdir (default: 0.3.1)
tsort (default: 0.2.0)
typeprof (0.31.1)
un (default: 0.3.0)
uri (default: 1.1.1)
weakref (default: 0.1.4)
yaml (default: 0.4.0)
zlib (default: 3.2.3)

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head bc3d6042a2dd6b82660ae023c0e74d1766025bd1 against fetched main 323706a71663464523037f00155a5c79917caa7e, including parser markers, reflection, evaluator/VM forwarding, bare super, frame storage/capture and GC marking. Existing reviews, discussion and inline threads were empty; no tracked AGENTS.md or CLAUDE.md was found. No new actionable findings.

Reusing the immutable internal-list form keeps private forwarding storage out of Ruby's Array counts without hiding real Arrays. The inaccessible marker is consistently updated across parsing, VM local naming and reflection, while named rest parameters retain their observable Array behavior.

Independent focused validation on Darwin arm64: corpus 989 matches all 22 reference output lines in evaluator and VM modes with GC stress period 50, including escaped closures, repeated GC, Fiber, blocks/keywords, exception cleanup and 10,000 arguments. Six existing forwarding/Binding/super regressions and an additional user-local/redo probe also match the independent Ruby 4.0.10 reference in both modes: 16/16 executions overall. All nine source gates and diff whitespace checks pass, including GC-root accounting on the restored exact-build generated C and bracket depth 155 against the unchanged 1024 bound.

Build reuse is explicit: I verified all 2,425 tracked files against fetched head and the clean pinned mgz commit 661a01d8, then copied the existing O2 executable. Its SHA-256 221de3245e2b3134b35f342bf4bd291ef249c9be4c27d5ec66d6a521136ea93e matches the exact-head build manifest; the recorded pinned compiler is 9dec2ff6. This is not a fresh compilation.

The prospective current-main integration is conflict-free (tree bd0f903069dd79b6df7ce2c2ed08df7713af9bd7) but was not built or executed. Full corpus, allocation-file counts/RSS, performance and affected-platform resource acceptance were not independently rerun here. Hosted Linux/macOS builds and reference preparation have succeeded; corpus, all eight CRuby shards, all four bootstrap shards, basic and tool coverage remain queued, with a supplementary gem job executing. Broad acceptance remains incomplete. Draft state and the recorded global merge holds prevent merging; these focused passes do not clear historical failures or relax their original bounds. COMMENT is used because the authenticated account owns the PR.

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review of exact head b659812c6831b840cdf3bcbcb467d4491a465ef7, compared with previously reviewed bc3d6042 and fetched current main ec980154. Existing reviews, discussion and the empty thread inventory were read. No tracked AGENTS.md or CLAUDE.md instructions were found. No new actionable code finding.

This update cleanly merges main d03cbb83 and updates the measurement note. The merge has no manual conflict-resolution diff; the private forwarding marker, native frame storage, GC traversal, evaluator/VM expansion and parameter reflection remain consistent. A prospective merge with current main is also conflict-free. The note correctly labels the earlier allocation/performance figures as historical and acknowledges the future integration overlap with PR242's keyword-origin work.

Independent Darwin arm64 validation: five focused programs match independent Ruby 4.0.10 on stdout, stderr and exit status in evaluator and VM, all with GC stress period 50 (10/10 executions). Corpus 989 retains its 22 matching output lines, escaped closures, repeated GC, Fiber, 10,000 arguments and private-slot isolation. Related forwarding, ruby2_keywords/bare-super, Binding/ObjectSpace and reassigned keyword-rest regressions also pass. All nine source gates and default record_hygiene pass. Bracket-depth acceptance used the restored exact-build C via MR_C and verifies depth 155 against the unchanged 1024 bound; the initial invocation without MR_C was a local setup error and is not a code failure.

Build reuse: all 2,449 tracked files byte-match the existing build checkout, with zero differences; imported mgz sources match pin 661a01d8, and the compiler checkout is clean at 9dec2ff6. The successful ordinary O2 build was copied; binary SHA-256 89436ae9803aa828a088eff7ee5731408805042849d894939b614543d7e6d1d6. No fresh compilation, full corpus/allocation-file/performance rerun or current-main integration execution is claimed.

Hosted CI has a real failure, not solely runner queueing. Linux job 138937095696 builds successfully, then headers_check.py rejects capi/vendor/erb_escape.c before the C API suite. I reproduced the identical rejection using the pinned Ruby source a704b7cd on both this head and a separate export of current main ec980154; the checker and vendored file are byte-identical between them. This establishes an inherited main failure, not a forwarding regression. It remains a genuine failing check: later corpus, VM, native/resource and Module steps were skipped, and macOS/reference/downstream coverage is incomplete. No passing platform acceptance is inferred.

No merge: this PR remains draft, the executed Linux check is failing, and the recorded global hold_all_merges / new_failure_review_required conditions remain active. Historical failures and original resource bounds are preserved. COMMENT is used because the authenticated account owns the PR.

@284km

284km commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

The Linux failure is inherited from main and occurs before runtime validation: headers_check.py looks for vendored erb_escape.c at the Ruby tree root instead of ext/erb/escape/escape.c. I reproduced it on the unchanged d03cbb8 main control. The independent fix is #273, which retains byte-for-byte validation and rejects tampered/missing upstream files. This PR remains draft while that CI dependency is resolved; its current-head local corpus, VM and source-gate results are in the description.

@284km

284km commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner Author

Rails-1 follow-up: the remaining three ActionMailer REDs are not specific to a block: both implicit super and super(*args) from a ruby2_keywords method lose the marked keyword tail when the next Ruby method declares .... Straight marked initializer, method_missing forwarding and alias-send controls still pass.

The isolated candidate is 04e11f7091ffa20fe6772b5068f58b36105ffa92 (not pushed yet). In bind_params, the existing pending-splat/marked-Hash branch now also applies to *__fwd forwarding parameters, in addition to explicit keyword parameters. Direct-super, block-super, explicit-spread-super and positional negative controls pass against clean Ruby4.0.10 in all eight evaluator/VM, Hash-index and GC32 configurations. Full corpus and related core-file checks are queued under the shared two-slot limit.

Your native frame/storage implementation is untouched. If #245 renames the forwarding parameter marker to *__fwd~args, this semantic check needs the corresponding marker adjustment when integrating. The other17 Mailer REDs have a separate Array override/index-coercion candidate. I will post the focused/full framework results after the fresh native install completes.

@284km

284km commented Dec 3, 2026

Copy link
Copy Markdown
Owner Author

Addressed the integration follow-up in ea0d701, a normal merge of main 3c58e04 into this branch.

The private native forwarding slot now consistently retains main's #242 keyword-origin behavior, including the marked-super correction discussed in #245 (comment). The native-list bare-super path reapplies saved __fwd~kw on repeated calls, just as main's Array path does. Anonymous-rest optimizations remain in place. Added regression cases for repeated super across GC, synthesized Struct[] forwarding, and both implicit/explicit super from ruby2_keywords callers into a parent declaring ....

Fresh ordinary O2 build with the current CI compiler pin 72bb0d09 and mgz 661a01d8: corpus 987 and expanded 989 pass on evaluator/VM with both hash-index modes at GC stress 32; 989 has 26 matching lines. VM=why confirms both programs execute on the VM. Across ten focused programs, all 40 stdout/exit comparisons match Ruby 4.0.10, and 36 match stderr exactly. Corpus 343's four stderr differences are an inherited warning: a separate fresh O2 build of current main gives identical stdout/stderr/status in all four modes. This is explicitly recorded rather than counted as a strict 40/40 pass. Source gates, class-watermark controls, record_hygiene and generated-C depth 155/1024 pass.

The PR body and committed note now separate this functional integration from the historical allocation/instruction/RSS measurements (b659812/d03cbb83, compiler 9dec2ff6). No new resource acceptance is claimed; the higher allocation-file and VM literal peaks remain open, and this remains draft. The previously reproduced inherited header-check failure has its #273 correction included through main; fresh hosted CI still needs to validate the integrated head. No full-suite/performance rerun, relaxed resource bound or PR merge is claimed. Existing merge holds are preserved.

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review of exact head ea0d70126e6015808e1a6391f40b9e835131555e against freshly fetched main 3c58e0494d2b28b3f7e1aa1211e7bd3dc678ec5e. Head already contains current main; its tree and prospective integration are both f2f3cb20289614dc37b04f2d3c6f3862fde67cd7. Existing reviews and all discussion were read; there are no review threads. No new actionable findings.

The integration consistently uses __fwd~args in parsing, parameter reflection, VM local naming/forwarding, binding and synthesized Struct wrappers. Bare super reapplies saved keyword provenance for the native-list payload on every call. Existing anonymous-rest behavior is retained, and GC follows the payload's Ruby values through the owning frame/closure. The added repeated-super and ruby2_keywords-to-forwarding cases exercise the integration concern from the earlier discussion.

Independent validation on macOS arm64 with Ruby 4.0.10:

  • Ten focused corpus programs, four evaluator/VM and hash-index configurations, GC stress 32: 40/40 stdout/exit matches; 36/40 exact stderr matches. The four corpus-343 diagnostic mismatches reproduce byte-for-byte on current main, including stdout/status; they are inherited warning differences, not strict reference passes. Expanded corpus 989 matches all 26 output lines in every mode.
  • Additional marked-Hash positional/splat/keyword controls, repeated bare super through a Fiber, and escaped forwarding closures surviving frame reuse/GC: 8/8 exact stdout/stderr/status matches across current main and head, both engines/index modes, GC stress 32.
  • MERE_RUBY_VM=why confirms corpus 987 and native-forwarding corpus 989 execute on the VM.
  • StrBuf-region, GC-root, duplicate/dead-definition, method/ivar-write, name-spec, namespace/name-length and regexp-capture checks pass. Exact generated-C bracket depth is 155 against 1024; record_hygiene passes for 343 files. PR diff whitespace checks pass. No tracked AGENTS.md or CLAUDE.md exists on current base/head.

Build reuse is explicit: all 2,903 tracked entries byte-match the existing exact-head ordinary O2 build checkout, as do all 18 files of pinned mgz 661a01d8. Reused binary SHA-256 286b9dd159b29ccef6971d2eb0c0b2b74a80e7c5b6fd0810b859c4aa7dd1e57d, built with current CI-pinned Mere 72bb0d09; no new full compilation. Freshly regenerated C with that clean exact-revision compiler for GC-root validation after the copied C's timestamp guard correctly rejected the initial setup; that rejection was not a program failure. Main controls reuse the byte-verified current-main O2 binary recorded in today's #417 follow-up.

Resource acceptance remains open: the historical allocation-file and VM literal RSS increases are not resolved or remeasured here. No full corpus, allocation-file, performance or affected-platform memory acceptance is claimed. The inherited header-check correction is included through main, but exact-head Linux/core/downstream validation remains incomplete. Current Wasm job 144012474899 failed after a runner shutdown/exit 143 during the smoke check; the log does not demonstrate a forwarding assertion failure or a completed Wasm pass. Latest main has a separately preserved Wasm runner-shutdown failure. This is not solely unassigned runner queueing.

No merge: the PR remains draft, resource/platform acceptance is incomplete, and recorded global merge holds remain active. Historical failures and original bounds are preserved. COMMENT because this is the authenticated user's own PR.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant