Skip to content

Reuse fresh keyword packets for pure keyword rest parameters - #256

Merged
284km merged 28 commits into
mainfrom
codex-keyword-rest-ownership
Nov 28, 2026
Merged

284km merged 28 commits into
mainfrom
codex-keyword-rest-ownership

Conversation

@284km

@284km 284km commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

PR #251 is merged. This runtime integrates its post-merge main 40b2563, including the current C API buffer allocator, backtrace-node fixes and reference-aware class-watermark gate. The measurements below compare that actual main with the integrated ownership runtime; the older pre-integration measurements are not relabeled.

A completed fresh call-site keyword packet can become the callee's named keyword-rest Hash without a redundant allocation. Borrowed, forwarded, permanently flagged and ObjectSpace-published arguments retain their separate ownership rules. Native copies do not call user dup/initialize_copy hooks.

Bare super restores the invocation's original keyword origin even after an earlier call consumed the transient flag. Repeated super and consume-then-super therefore give each receiver its independent Ruby-visible keyword-rest Hash. Corpus 994 checks callback exposure, restoration and repeated-super identity; corpus 995 retains the prerequisite snapshot/isolation/exposure controls. The updated main backtrace-node corpus is also replayed.

The owner-requested ordinary method/block/matrix instruction rows are newly measured after #251 merged. The parent's one pending-source comparison is already in this main baseline. Positive measured rows remain explicit; no count-only per-call work or dummy Ruby object is introduced.

Validated runtime f21fc4cea8bf7338ce04af03d2decc9ac9151ed1 against main 40b25633a699b24704335d95feb540cf3bb82a9c. Documentation-only publication preserves this exact source, generated C, binaries and regression inputs.

Complete upstream files

Seed 1; complete unchanged files, with no new RED, BOTH or EXTRA. No driver bound, exclusion, budget, GC policy or allocation counter is changed.

File / engine Main MATCH / RED This runtime MATCH / RED
ruby/test_keyword.rb / evaluator 115 / 0 115 / 0
ruby/test_keyword.rb / vm 115 / 0 115 / 0
ruby/test_call.rb / evaluator 65 / 0 65 / 0
ruby/test_call.rb / vm 65 / 0 65 / 0
ruby/test_hash.rb / evaluator 298 / 0 298 / 0
ruby/test_hash.rb / vm 298 / 0 298 / 0
ruby/test_allocation.rb / evaluator 14 / 62 18 / 58
ruby/test_allocation.rb / vm 14 / 62 18 / 58

The Hash file has no RED cases in either mode. All 76 allocation cases run; the full upstream suite and Rails cold measurement are not run.

Allocation causes

Groups count mismatching assertions, with overlapping case sets. Missing CRuby temporary Arrays/Hashes remain reported; no unused objects are manufactured.

Engine / cause Main assertions (cases) This runtime assertions (cases)
evaluator / extra Arrays 116 (4) 116 (4)
evaluator / absent CRuby Array temporaries 346 (46) 346 (46)
evaluator / extra keyword Hashes 504 (38) 280 (26)
evaluator / absent CRuby Hash temporaries 8 (4) 8 (4)
evaluator / missing ruby2_keywords copies 8 (4) 8 (4)
vm / extra Arrays 116 (4) 116 (4)
vm / absent CRuby Array temporaries 346 (46) 346 (46)
vm / extra keyword Hashes 504 (38) 280 (26)
vm / absent CRuby Hash temporaries 8 (4) 8 (4)
vm / missing ruby2_keywords copies 8 (4) 8 (4)

The case and atomic mismatch tables are computed from these actual integrated runs. Keyword-rest packet reuse removes redundant observable Hash copies without hiding real Ruby objects. The four improved Method/Proc allocation cases cover positional arguments plus keyword rest, with and without blocks. Remaining generic ... rest Arrays belong to PR #245. Literal keyword packets, named-keyword filtering, native ruby2_keywords copies and source-Hash metadata remain separate follow-ups. Missing CRuby rest/concatenation Arrays and empty merger Hashes stay recorded as not matched rather than being synthesized. Every original case and assertion remains in the harness.

Reference source inspection is pinned to Ruby a704b7cd: vm_args.c arg_rest_dup/args_copy and the Prism/legacy argument compilers (prism_compile.c and compile.c setup_args_core) explain the additional CRuby splat/rest Arrays. Reference bytecode for none(*a, *a) emits splatarray true and concattoarray; none(**h, **h) emits an intermediate newhash plus two core#hash_merge_kwd calls even when h is empty. mere-ruby can retain native lists or elide an empty merge instead. Extra real keyword packets and required ruby2_keywords semantic copies remain optimization work; they are not declared fundamentally unmatchable. See the pinned Prism argument compiler and VM splat helper.

Instructions retired

Same inputs and stdout, ordinary O2 builds; counts include startup.

Workload / engine Main This runtime Change
method_call.rb / evaluator 3,463,836,274 3,442,440,820 -0.618%
method_call_200k.rb / evaluator 5,936,215,730 5,937,498,091 +0.022%
block_call.rb / evaluator 4,291,910,039 4,292,176,045 +0.006%
block_call_200k.rb / evaluator 7,622,645,512 7,626,033,613 +0.044%
so_matrix.rb / evaluator 201,054,215,421 201,047,883,870 -0.003%
method_call.rb / vm 3,734,220,335 3,733,145,269 -0.029%
method_call_200k.rb / vm 6,517,285,337 6,518,073,190 +0.012%
block_call.rb / vm 5,162,221,123 5,164,338,508 +0.041%
block_call_200k.rb / vm 9,365,317,999 9,365,888,722 +0.006%
so_matrix.rb / vm 215,424,134,274 215,408,285,831 -0.007%
keyword_rest_method.rb / evaluator 4,931,200,590 4,833,480,167 -1.982%
keyword_rest_proc.rb / evaluator 5,995,186,803 5,894,730,490 -1.676%
keyword_rest_lambda.rb / evaluator 7,102,711,777 6,995,012,435 -1.516%
keyword_rest_method.rb / vm 4,951,620,405 4,844,435,542 -2.165%
keyword_rest_proc.rb / vm 6,207,148,090 6,093,036,838 -1.838%
keyword_rest_lambda.rb / vm 7,331,082,402 7,215,234,659 -1.580%

The requested instruction rows are measured on the actual post-PR251 main40b25633 and integrated runtimef21fc4ce. Ordinary method/block/matrix totals range from -0.618% to +0.044%; all positive rows remain explicit. Method/Proc/lambda keyword-rest controls improve 1.516% to 2.165% on both engines. The owned-packet operation stays inside the existing keyword-rest binding path; ordinary calls receive no new count-only operation or dummy Ruby object. The prerequisite pending-source comparison is already present in this main baseline. These data support final correctness/resource validation and make no claim of external approval or universal zero overhead.

Controlled maximum RSS

Whole allocation file alone, GC_TIGHT=1 and seed 1. Kernel command/child high-water marks and sampled simultaneous family peaks are different measurements; all are retained.

Engine Kernel command bytes main → runtime Largest child bytes main → runtime Sampled family KiB main → runtime
evaluator 311,345,152 → 311,558,144 (+0.068%) 311,345,152 → 311,558,144 (+0.068%) 520,992 → 399,360 (-23.346%)
vm 317,734,912 → 318,013,440 (+0.088%) 317,734,912 → 318,013,440 (+0.088%) 496,528 → 421,168 (-15.177%)

The whole allocation file was measured alone with GC_TIGHT=1 and fixed seed 1 on both exact builds. Evaluator command and largest-child high-water marks rise 0.068%; VM command and largest-child marks rise 0.088%. These positive deltas remain explicit rather than being rounded to a memory reduction. Sampled simultaneous family RSS falls on both engines (evaluator 520,992 to 399,360 KiB; VM 496,528 to 421,168 KiB). Family samples measure concurrent wrapper/runner/forked-child pages separately from kernel per-process high-water marks. All 76 cases complete and match the corresponding ordinary-GC case results. The sub-0.1% per-process changes and lower family peaks show no material memory regression in this controlled local pair; this is local assessment, not external review or platform acceptance.

Final local acceptance

  • Full corpus --both: 1031/1031, hash index ON and OFF.
  • VM corpus: 1031 VM / 0 fallback / 0 differences / 0 failures; no fallback-list mismatch.
  • 32 focused engine comparisons match clean reference stdout, stderr and exit status, including stress50 regressions.
  • All ten source gates, record_hygiene before/after, header/vendor, CI-timing and class-watermark runtime checks PASS. Corpus driver runs the iv-door and shape-statistics preflights.

Own full corpus sweeps are serial; allocation measurements have no supplementary runtime from this session. Shared heavy cap: two across Codex sessions. Code and records are published in one batch. Hosted queued checks and reviewer approval remain separate from executed local passes. The owner performs the merge.

Reference: clean independently built Ruby 4.0.10, revision a704b7cd95a42cc0cf5f307137bf3aac0285b915, 46 default / 38 bundled / zero extra gems, Prism 1.8.2. Compiler 9dec2ff687a08433247dbdb7729bc19c8522e538, mgz 661a01d8bb68f5acd68e3192bd47f081d179c436.
Binary SHA-256 5cef5a44684f0bec56a0435fa14fdcea178aa188836a272b89b3fa5835433329; generated C 8e00a820bbe422889630f24a4910b6952b9b5288ef7ba420cd15a896a0ace8c0.

Record: loop/2026-11-28-codex-keyword-rest-ownership.md.

Reference executable: /private/tmp/mere-reference-ruby-4.0.10-install/bin/ruby, SHA-256 5ad9092ceb67b18b9ed512ad3fbcf309910c7ad7d2fabb3d85d5228a51eb8df0. No gems were installed into its default gem directory.

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 a7f3eca355fc815bcf179db65edcfd1beb85d8e5 against fetched current main 8b1b95256644eb7f5714ddb3094701f2ea3366bb, including the changed implementation, callers, regression programs and validation record. Existing reviews, discussion and inline threads were read. Neither base nor head contains tracked AGENTS.md/CLAUDE.md instructions.

One Major/P2 regression is attached. Consuming keyword origin in a callee leaves a generic-forwarding frame unable to reconstruct keywords for a later bare super. The frame-local origin bit is restored for explicit (...) but is not consulted by zsuper_all. Repeated bare super has the same failure. The borrowed/fresh distinction and the ObjectSpace exposure regressions otherwise provide useful ownership coverage. Additional three-way controls reproduce both failures on evaluator and VM under GC stress50, while explicit super(...) succeeds; independent Ruby and an older-main control succeed on all three. Fetched current-main source retains the prior non-consuming binder and lacks this new forwarding failure. The documented pre-existing Hash metadata-copy limitation is not a new finding.

Independent Darwin arm64 validation: 2/2 focused executions match stdout, stderr and exit status from independent Ruby 4.0.10, in evaluator and VM modes with GC stress period 50. Programs: 990_keyword_rest_packet_ownership.rb. Seven source gates (duplicate/dead definitions, method writes, name specifications/lengths, namespace names and regex-capture writes) and diff whitespace checks pass.

Build reuse: verified all 2,441 tracked files against the exact head (zero differences), all three imported mgz modules against pin 661a01d8, ordinary O2 build mode and the successful build log using pinned compiler 9dec2ff6 (its checkout was verified clean). Reused binary SHA-256 4b93be2d3be1ec9fc82052f31c394b89e62fdee8e8f3e7b9ee94b739d565cdb3. This is not a fresh compilation or a tested current-main integration build.

I did not independently rerun the full corpus, complete upstream files, performance measurements or platform/resource acceptance. Those reported results and pending sweeps remain separate from these focused checks. Hosted build/downstream coverage remains incomplete. No merge: the PR is draft and recorded hold_all_merges / new_failure_review_required conditions remain active. COMMENT is used because the authenticated account owns this PR.

Comment thread main.mere Resolved

@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 a96aeef183f997fc05346cd20a76b0e467d55777, compared with its previously reviewed head and fetched main f52b0f5b1afbdb1ff16fc0bae98f6f3a9f57b17e. I read the existing review, inline finding, updated description and changed implementation/regressions. Neither fetched base nor head has tracked AGENTS.md/CLAUDE.md instructions.

The previous Major/P2 bare-super finding is fixed. zsuper_args restores the forwarding frame's saved keyword provenance at each implicit-super boundary and restores it as borrowed origin, preserving independent callee keyword-rest Hashes. Corpus 990 now exercises consume-then-super, repeated bare super and Hash identity. I found no additional actionable issue in this update; this does not establish whole-suite acceptance.

Independent Darwin arm64 checks: all 19 stdout lines, stderr and exit status match clean Ruby 4.0.10 in evaluator and VM modes, both normally and with MERE_RUBY_GC_STRESS=50 (four matching executions). Duplicate-definition, dead-definition, GC-root and diff-whitespace gates pass. The GC-root gate used the existing generated C after exact-source verification; the fresh source-only checkout had no generated C.

Build reuse: all 2,441 tracked regular files match the fetched exact head byte for byte; mgz is clean at pinned 661a01d8bb68f5acd68e3192bd47f081d179c436. I checked the successful ordinary O2 build log using compiler 9dec2ff687a08433247dbdb7729bc19c8522e538 and its clean checkout. Reused binary SHA-256: ad8954969b1ddb0bbae8e3acbbd17e34f36921c9f1f1389106ff5e4494ce1737. This is exact-head focused validation, not a fresh build or a tested integration with newer main.

Final-head full corpus, complete allocation file, performance and platform/resource acceptance remain pending as stated in the PR. Hosted build/downstream coverage is incomplete. No merge: the PR remains draft, and the recorded hold_all_merges / new_failure_review_required conditions remain active, including an uninvestigated main corpus failure. Latest main CI run 45537130202 is pending with zero jobs exposed by the API; that is not a passing or equivalent validation result. COMMENT is used because the authenticated account owns the PR.

284km added 22 commits November 25, 2026 16:19
@284km
284km marked this pull request as ready for review November 27, 2026 01:24

@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.

Re-reviewed exact integrated head 6f58069c09f469b23e4f6a649b8832a763769821 against current main b9ca06d6700c44ded301131930a5dbd9107202be, including the prior finding/replies and the unmerged #251 dependency. No new actionable finding established; the earlier Major/P2 bare-super fix is retained. Repeated/consume-then-super restores borrowed keyword provenance, and the resulting callee keyword-rest Hashes remain independent. Separating fresh ownership from forwarded, permanently flagged and ObjectSpace-published packets is appropriate.

Independent Darwin arm64 validation: 32 main/head executions of corpora 994 and 995, on evaluator/strict VM with hash index ON/OFF, normally and under GC stress50 (tight GC also enabled), against Ruby 4.0.10. All 16 head comparisons match stdout, stderr and exit status, including callback exposure, anonymous-rest publication, consume-then-super and repeated-super identities; main differs in these changed corpus outputs. Nine source gates and generated-C bracket depth (155/1024) pass. The prospective current-main merge is source-clean; no integration binary was tested. No tracked AGENTS.md/CLAUDE.md exists.

Reused the recorded ordinary O2 head binary 446bc857... in an isolated snapshot after verifying all 2,757 tracked files before/after copying, committed binary/generated-C digests, and pinned mgz 661a01d8 blobs. Recorded build runtime e4d98db and this published head differ only in documentation/records, with runtime/build inputs unchanged; pinned compiler is 9dec2ff6. Main uses the previously verified O2 binary for current b9ca06d. No fresh compilation or independent complete-file allocation/RSS/PMU/full-corpus/platform rerun is claimed. Earlier complete-file/resource measurements remain tied to their original pre-integration runtime, as the description correctly distinguishes.

No merge: #251 must merge first, hosted coverage remains incomplete, and recorded hold_all_merges/new_failure_review_required remains active. The executed main Linux network contract failure is not unassigned-runner queueing. Existing review threads were left untouched. COMMENT because the authenticated account owns this 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.

Review of 6f58069c. This head contains #251's current head and four commits of its own (the bare-super keyword-origin restore). I will review and merge it after #251, whose general call-cost Minor is still open, since the same method_call/block_call rows are in this description too (+0.10% to +0.28% on the evaluator, before integration). Once #251 is settled and merged, please merge main here and post the instruction rows on the integrated runtime.

@284km

284km commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

PR #251 is merged, and this push integrates its post-merge main 40b25633. The measured runtime is f21fc4ce; publication fddf3b87 adds only the records, with runtime inputs, binary, generated C and all corpus inputs verified unchanged.

All requested instruction rows are freshly measured on the integrated main/head pair in the updated description. Ordinary method/block/matrix totals range from -0.618% to +0.044%; keyword-rest method/Proc/lambda controls improve 1.516–2.165%. Positive rows remain visible.

Final local results:

  • Corpus --both: 1031/1031, hash index ON and OFF.
  • VM corpus: 1031 VM / 0 fallback / 0 differences / 0 failures.
  • All ten source gates, record_hygiene before/after, header/vendor, CI timing and class-watermark checks pass; the corpus driver runs iv-door and shape-statistics preflights.
  • Complete unchanged keyword/call/Hash files match main on both engines: 115/0, 65/0, 298/0 MATCH/RED. All 76 allocation cases run: 14/62 → 18/58, with no new RED on either engine.
  • Whole allocation file alone, GC_TIGHT=1, seed 1: command/largest-child RSS +0.068% evaluator and +0.088% VM; sampled family RSS decreases on both. All values and measurement distinctions are retained in the description.
  • 32 focused engine comparisons match clean Ruby, including stress50 controls. Reference Ruby 4.0.10 has 46 default / 38 bundled / zero extra gems; the description includes its revision, executable location/digest and gem list.

Exact published-head validation record. The existing bare-super finding remains fixed. The PR stays Ready; exact-head automated review and hosted checks remain separate from these local results. The owner performs the merge.

@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 fddf3b874eb57bc62f4ce5cddf24723c70f5237a, including the existing reviews, resolved finding and replies, current discussion, implementation/callers, corpus and published validation records. I fetched current main 491cc5cab7e727606e1b00a141607e4742194d0a; the PR's integrated post-#251 baseline is 40b25633a699b24704335d95feb540cf3bb82a9c. No tracked AGENTS.md or CLAUDE.md exists on either fetched tree.

No new actionable finding established. The earlier Major/P2 bare-super issue remains fixed: each implicit-super boundary restores borrowed keyword provenance, preserving separate callee keyword-rest Hashes. Fresh ownership is withheld for forwarding, permanently flagged and ObjectSpace-published packets. Acquiring a block's keyword-rest packet before default callbacks while retiring argument origin before those callbacks preserves the newly added positional-origin control. #251 is merged. The newly reported instruction/RSS comparisons are explicitly tied to the integrated runtime and retain their positive deltas.

Independent Darwin arm64 validation: corpora 994 and 995 match clean Ruby 4.0.10 stdout, stderr and exit status in all 16 executions: evaluator/VM, hash index ON/OFF, normally and with GC stress50 plus tight GC. This covers packet exposure, default callbacks, anonymous-rest isolation and consume-then/repeated bare super. Seven source gates, the GC-root gate and generated-C bracket-depth check pass (155/1024); diff whitespace also passes.

Build reuse was explicit: all 2,835 tracked regular files matched the existing build snapshot byte for byte; all three imported mgz sources matched pin 661a01d8. I checked the successful ordinary O2 build log and clean compiler checkout at 9dec2ff6. The isolated test copy uses binary SHA-256 5cef5a44684f0bec56a0435fa14fdcea178aa188836a272b89b3fa5835433329 and generated C 8e00a820bbe422889630f24a4910b6952b9b5288ef7ba420cd15a896a0ace8c0. The GC-root check used a newly copied, digest-verified C file after its timestamp guard rejected the preserved old timestamp. No fresh compilation, current-main integration build, independent full-corpus/whole-upstream-file rerun, PMU or resource/platform acceptance is claimed.

No merge. The latest PR core CI run 46087612882 still has build-linux executing, with build-macos and unittest-reference queued; downstream matrices are incomplete. The latest main core CI run 46078134440 has 12 successful, one skipped, three running and six queued jobs at inspection. Recorded hold_all_merges / new_failure_review_required remains active, including the recorded unreviewed main build failure; these observations do not clear it. This applies to the other open, previously reviewed merge candidates as well. In-progress work and incomplete downstream coverage do not qualify for the unassigned-runner queue exception. Published author validation remains separate from the independent checks above. COMMENT because the authenticated account owns this PR.

@284km
284km merged commit 856e61b into main Nov 28, 2026
13 of 19 checks passed
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