Repository navigation
Preserve Array operator element lines without repeated line scans - #272
Conversation
There was a problem hiding this comment.
Reviewed exact head 6709c57605625d4a51cdc1533dd1911a961f9e55 against fetched current main a63e47c366505074dab80db9285b8a7b3b6d051b. Read the full diff, surrounding parser/line annotation paths and callers, description, record and existing discussion (no prior reviews/threads). No tracked AGENTS.md or CLAUDE.md was found. No actionable finding established.
The cache retains only integer counters and conservatively invalidates when parsing observes a different line; continued logical lines retain physical-position lookup. Literal elements avoid the new lookup. The regression covers both eval and actual child files, nested/continued lines and the large computed literal.
Independent Darwin arm64 validation: corpus 992 matches all 29 stdout lines, stderr and exit status from clean Ruby 4.0.10 in evaluator and VM modes. Seven related corpus programs 980–986 also match in both modes (16 successful corpus executions total). An additional seven-shape multiline String/operator/nested-expression probe matches in both modes. Duplicate/dead-definition and diff whitespace checks pass.
Binary reuse, not fresh compilation: all 2,442 tracked regular files match the exact head byte for byte in the existing build source. Its successful ordinary O2 build log identifies compiler checkout 9dec2ff6 (independently checked at that revision); copied binary SHA-256 29b1e5bd472f051cecd1b8831682c928ba4a4cdfb467b5a27a6cb90021265592. No independent complete corpus, allocation-file, hardware-instruction, upstream whole-file or Linux/resource acceptance run is claimed here.
Hosted unittest-harness is failing; build-linux and other Linux work are executing, while macOS/reference and downstream coverage remain incomplete. This is not solely unassigned runner queueing. No merge: draft state and recorded global merge holds also prevent it. COMMENT because the authenticated account owns the PR.
284km
left a comment
There was a problem hiding this comment.
Follow-up on unchanged head 6709c57605625d4a51cdc1533dd1911a961f9e55. No new actionable code findings or unresolved inline findings. The previous review remains the independent focused runtime evidence; those tests were not repeated in this follow-up.
The updated description now reports completed evaluator and VM corpus sweeps, 893/893 in each engine with hash indexing on/off, source gates and record hygiene. These are author-reported results, separate from the earlier independent checks. The committed loop note still describes the sweeps as running, which the description explicitly explains.
Newly completed hosted results require a readiness update. I read the actual failure logs for CI run 45542060289, whose checkout was integration 6f6756c1a87fad40bbcf382c5a4e7b87cd6290e9 (head above into base a63e47c3):
- unittest-harness: the timing-report dependency assertion fails because
unittest-vmis absent fromci-timing.needs. - build-linux and corpus: both fail at the C-source comparison,
capi/vendor/erb_escape.c is not the tree's file. The corpus job's failure is not evidence of an Array corpus mismatch.
This PR changes none of those workflow/checker/vendor inputs. Fetched current main 34ba9660efa9839666a999c4877b8a6a24395f99 already includes unittest-vm in the timing dependency list and explicit upstream-path mappings for the renamed vendored sources. Those source fixes do not retroactively turn this PR's failed jobs green. No new runtime regression is established by these logs, and no passing current-main integration CI is claimed.
A fresh temporary clone was used; neither current main nor head has tracked AGENTS.md/CLAUDE.md instructions. Current-main merge-tree is clean (tree 8c4d369f830dd9801ecc9d2da73509a0a5310a86), and its diff whitespace check passes. This is a source preflight, not a built/tested integration. No fresh compilation, complete corpus/upstream-file run or platform/resource acceptance was performed here.
No merge: this PR remains draft, actual failed checks and running/incomplete downstream coverage remain, and recorded hold_all_merges / new_failure_review_required conditions remain active. The queue-only exception does not apply. Latest main CI run 45625765116 is pending with zero jobs exposed at inspection; it does not clear historical failures. Already-reviewed ready PRs were also reconsidered: #254 still has a failed Linux build, and #288 retains the existing Major GC finding. COMMENT because the authenticated account owns this PR.
284km
left a comment
There was a problem hiding this comment.
Reviewed 6709c57. The line-number fix works; two things block the merge.
What I ran (the author's build at this head, the evaluator and MERE_RUBY_VM=1, against ruby 4.0.10, plus a main build d586947 for comparison):
- corpus 992: identical on both engines.
- A probe of multi-line Array literals inside blocks (
o + 1on a later line,-o,"#{o}", a 5-element literal continued on the next line): the lines now match ruby on both engines; main's evaluator reports the opening line (4 / 10 / 12 / 15 where ruby says 6 / 11 / 13 / 16). - The same probe including
def o.-@ = ...fails to parse on this branch. That is only because the branch base (323706a) predates #277; main parses it. - A Hash value on a later line (
{a: 1,\n b: o + 1}) still reports the line before on the evaluator (17 vs ruby 18). main does the same, so this is outside this PR — a follow-up.
Minor 1: the cost is worse than main in two places (from the description's own tables).
- 100,000-element operator Array: max RSS 222.9 → 237.2 MB (eval) and 223.8 → 238.1 MB (VM), about +14 MB.
- The computed 100,000-element Array: 2.262 → 2.365 G instructions (+4.5%) on the evaluator, and about the same on the VM.
- Plain literal Arrays and Hash keys are level (+0.1–0.3%), which is good.
Our policy is that anything worse than main is fixed in the PR. Could the annotation be skipped when the element is on the same line as the previous one (or the array's opening line), so only elements that actually change line carry a node? Please post instructions and GC_TIGHT max RSS for the operator and computed Arrays after the change. (The elapsed seconds in the table are too noisy on a busy host to judge either way.)
Minor 2: the base is far behind main. It starts at 323706a; since then main has had many parser changes (#247, #263, #277 among them) in m_parse.mere. git merge-tree is clean, but please merge current main, rebuild, and re-post corpus --both, the MERE_RUBY_VM=1 corpus and the gates on the merged tree. The committed loop note still says the sweeps are running; please update it with the results.
No mere-pr-review-watch inline findings are open.
|
Addressed both review blockers in c43e079 (with integrated main 0369440). Repeated same-line operator elements share the existing annotation, removing the previous approximately 14 MB allocation increase. Updated fixed-seed GC_TIGHT measurements, retired instruction counts, RSS, and unchanged CRuby test comparisons are in the description and committed loop record. Both full sweeps on the corrected O2 binary pass: |
284km
left a comment
There was a problem hiding this comment.
Re-reviewed c43e079. Both Minors from the last review are addressed. (1) Cost: consecutive elements on the same line now share one annotation, so the ~14 MB extra on the 100,000-element operator Array is gone (max RSS +0.05%), and the computed Array's +4.5% is down to +0.5% on both engines. Plain Arrays are +0.3%, and Hashes are flat. The remaining +0.3–0.5% is parse time for a 100k-element literal, the cost of carrying real element lines. On behalf of the owner's policy, I accept this as the price of correctness: it is parse-only and tiny on ordinary programs. (2) Base: main is merged in and git merge-tree against current main is clean. I ran corpus 992 and my earlier probe (multi-line Arrays in blocks with o + 1, -o, "#{o}", and a continued 5-element literal) on the author's build at this head, on the evaluator and MERE_RUBY_VM=1, against ruby 4.0.10: identical. The description has corpus --both 954/954 plain and VM, the 8 gates, the bracket gate and test_backtrace. No mere-pr-review-watch inline comments. Merging.
Array elements that raise now report their actual source lines on the evaluator, including operators, interpolation and !call. The VM keeps its correct behavior. Main 0369440 is integrated, and the review's repeated-annotation allocation is removed.
Parser follow-up 6: Array element source lines
The evaluator now preserves the actual source lines of binary, unary,
interpolated String and !call elements in multiline Array literals.
Existing method, index and bare calls retain their correct lines. VM
backtraces remain correct. Corpus 992 contains 36 output rows covering
all shapes, actual files, nested expressions, continuations and heredocs.
Main 0369440 is integrated by merge 3c55355, including parser changes
#247, #263 and #277. Review corrections share the parser's observed-line
epoch across adjacent elements and emit a line annotation only when a
call-capable element changes line. Literal elements do not advance that
cache. A continued logical line uses its actual physical token position.
Only line numbers and epochs are cached; token tails are not retained.
No element rescans the remaining token tail. General ln_before behavior
outside this Array-specific path is unchanged.
Final measurements and related original CRuby tests
After merging main 0369440, corpus 992 matches all 36 rows, stderr and
status on evaluator and VM against clean Ruby 4.0.10. The ordinary O2
candidate SHA-256 is cde6d7d1c1aef9b58ecdb0476a17a6a3f3fe19a22c7707465d24046a95bf2f7c.
The matching main SHA-256 is 94473bd3a46d13124327720c4251a39f3604b584bafc4ef9c90ca670fe61a67c.
Three alternating main/candidate pairs, fixed --seed=1, GC_TIGHT=1:
Array/Hash sizes remain 100,000 elements / 50,000 keys. Operator arrays
contain 100,000 computed elements. The old ~14 MB annotation allocation
and ~4.5% instruction increase are removed; the remaining instruction
change is approximately 0.3–0.5% for Arrays and -0.03–0.09% for Hashes.
test_backtrace unchanged original selections, --seed=1, GC_TIGHT=1:
test_allocation unchanged original selections, --seed=1, GC_TIGHT=1:
Completed acceptance
sh run_corpus.sh --both: 954/954 PASS, hash index ON and OFF.MERE_RUBY_VM=1 sh run_corpus.sh --both: 954/954 PASS, hash index ON and OFF.name_spec, rx_caps, ns_names and name_len.
git diff --checkand staged whitespace checks PASS.tools/ref_ruby.sh.Measurements use fixed --seed=1 and MERE_RUBY_GC_TIGHT=1. The reference,
matching main, and both candidate engines run the unchanged related CRuby
selections one file at a time. No full unit or Rails component suite is
run; no workflow is changed. Ordinary O2, compiler 9dec2ff6, mgz 661a01d8.
The correction and this completed record are submitted in one push.
Median retired instructions from the same three alternating pairs: