Skip to content

CRuby's tests on the evaluator and on the ISeq VM, compared test by test - #265

Merged
284km merged 1 commit into
mainfrom
stage10-vm-unit-compare
Nov 25, 2026
Merged

284km merged 1 commit into
mainfrom
stage10-vm-unit-compare

Conversation

@284km

@284km 284km commented Nov 25, 2026

Copy link
Copy Markdown
Owner

#232's fourth proposal, as the owner decided. This changes .github/workflows/ci.yml (a new scheduled job): the owner reviews it before it is merged.

The record is loop/2026-11-25-stage10-vm-unit-compare.md; what follows is it.

#232's fourth proposal, as the owner decided: a script in unittest/ that compares the two executions test by test, and a scheduled job that runs it.

The script

sh unittest/vm_compare.sh <ruby-src> [--list FILE] [path under test/ ...]

It runs unittest/run.sh twice over the files, once with MERE_RUBY_VM unset and once with MERE_RUBY_VM=1, each into a record of its own (UNITTEST_RECORD_DIR). Each run is run.sh's as it is: the file under ruby and under mere-ruby, and a tag of each test mere-ruby did not pass. unittest/vm_compare.py then compares the two records:

VM_ONLY a test the evaluator passed and the VM did not
EVAL_ONLY a test the VM passed and the evaluator did not
VM_FILE a file the evaluator completed and the VM did not

A test the same build passes the other way is the VM's to answer for, so no baseline is needed: the evaluator is the baseline. Ruby is asked only what run.sh already asks it.

A difference is counted when it is seen twice. The files in which the two differ are run once more on both executions, and only what differs both times is reported. On the first local run below, three tests differed; two of them were time limits under a load of 30 (test_exception's test_blocking_backtrace, which has a 10 s bound, and test_syntax's test_invalid_symbol_in_hash_memory_leak) and did not differ the second time.

It exits 1 when a VM_ONLY or a VM_FILE remains.

The job

unittest-vm in ci.yml, on the weekly schedule and by hand (workflow_dispatch) only: it is two runs of the files on each side. It is set up as the unit-test shards are (the reference runtime, CRuby's test extensions built against mere-ruby's C API) and runs the script over unittest/vm_compare_files.txt, uploading the records.

The files are the 22 that rounds 60 to 65 compared by hand: test_require, test_autoload, test_parse, test_syntax, test_iseq, test_eval, test_regexp, test_rubyoptions, test_exception, test_backtrace, test_m17n, test_symbol, test_encoding, test_literal, test_hash, test_pattern_matching, test_compile_prism, test_ractor, test_transcode, test_mixed_unicode_escapes, and enc/'s test_shift_jis and test_euc_jp. The aim is test/ruby whole, when its time has been measured (after the Codex session's actionpack run, as agreed).

It runs run.sh directly, not through unittest/ci.py, whose shards check a measurement plan and give each side an emptied environment. Both executions get the same environment here, which is what the comparison needs; the records are not the shards' and are not merged into STATUS.md.

The first run

Locally, against ruby 4.0.10, on main 9d1948f, at a load of 30:

vm_compare: 22 files -- VM_ONLY 0, EVAL_ONLY 1, VM_FILE 0

1,712 tests; 39 minutes in all (the evaluator's pass 19, the VM's 17, the second run of three files 4). The one EVAL_ONLY is test_parse's test_method_location_in_rescue, which the VM passes and the evaluator does not (a method's source location under a rescue).

Checked

  • The script's exit: 0 on the run above; 1 with a VM-only failure written into the VM's record by hand.
  • ci.yml parses (the new job: two needs, nine steps). The job has not run in CI: it runs only on the schedule or by hand.

🤖 Generated with Claude Code

#232's fourth proposal. unittest/vm_compare.sh runs run.sh twice, with and
without MERE_RUBY_VM, and vm_compare.py compares the two records: a test the
evaluator passes and the VM does not is VM_ONLY, and fails the run. A file
that differs is run again, and only what differs both times counts.

A job, unittest-vm, runs it on the schedule and by hand over the 22 files of
unittest/vm_compare_files.txt.

@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 e40041b. No Critical / Major / Minor findings. This PR edits .github/workflows/ci.yml, so the owner decides whether to merge.

  • unittest/vm_compare.sh runs run.sh twice, on the evaluator and on MERE_RUBY_VM=1, into separate outputs. vm_compare.py then compares each test's tag against ruby. It reports VM_ONLY (passes on the evaluator, fails on the VM), EVAL_ONLY, and VM_FILE (the VM's run of a file does not complete). Files with a difference run a second time, and only differences seen both times count. VM_ONLY or VM_FILE exits 1.
  • The new job unittest-vm runs only on schedule and workflow_dispatch; the workflow already has schedule: cron "0 3 * * 1", Mondays 03:00 UTC. It is set up like the unit shards: the reference runtime, CRuby's test extensions built against mere-ruby's C API, and the 22 files in unittest/vm_compare_files.txt. It doesn't touch the shards' plan or provenance, and it doesn't run on pushes or PRs, so it doesn't slow ordinary CI.
  • The description's local run (main 9d1948f, ruby 4.0.10): 22 files, 1,712 tests, VM_ONLY 0, EVAL_ONLY 1 (test_method_location_in_rescue, which the VM passes and the evaluator fails). The two first-run timeouts disappeared on the second run, which is what the re-run rule is for.
  • git merge-tree against current main: clean. No mere-pr-review-watch inline comments.

@284km
284km merged commit a63e47c into main Nov 25, 2026
9 of 19 checks passed

@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 e40041bdfc92b978291b9fa88b02f9b69d3f24ea against its fetched base ec980154a5ab24cd4377db0dca60022b8a9decb0, including all five changed files, run.sh, file selection, transcript/tag production and the existing review/discussion. No tracked AGENTS.md/CLAUDE.md instructions exist at this head or current main. The author merged this PR at 03:15:08 UTC before this review completed; I did not initiate that merge. The affected comparator is byte-identical on fetched main a63e47c366505074dab80db9285b8a7b3b6d051b.

One new Major/P2 finding is attached: missing measurement records are treated as an empty comparison, so setup failures or a failed confirmation run can turn the new CI gate green without verifying the tests. This was not covered by the existing review. Keeping separate evaluator/VM records and requiring repeated differences are useful, provided missing evidence fails independently of the difference filter.

Independent focused validation on the exact head: a positive VM-only failure returns 1; a persistent VM-only failure still returns 1 with --both-times; matching records and a genuine transient difference return 0; an explicit incomplete VM file returns 1. However, empty records, a missing VM record, a missing VM file and a missing confirmation run all return 0. In particular, a known first-pass VM_ONLY failure disappears when the second records are empty. The actual shell wrapper also returns 0 for a nonexistent Ruby source tree, although both real run.sh invocations log source-validation errors. These are program results, not sandbox-denied executions.

Shell syntax, workflow YAML parsing (two dependencies/nine steps for the new job) and diff-whitespace checks pass. I have not rerun the reported 22-file/1,712-test measurement or executed the scheduled hosted job; no runtime build was needed for these comparator controls. Main CI run 45538694748 is pending with zero jobs exposed by the API, and the new comparison job intentionally does not run on a push/PR. No passing hosted execution is claimed. The recorded global merge holds remain active for further PRs; this observed external merge does not clear them. COMMENT is used because this PR is already merged and belongs to the authenticated account.

Comment thread unittest/vm_compare.py
ev_cov, ev_tags = evaluator
vm_cov, vm_tags = vm
found = []
for file in sorted(set(ev_cov) & set(vm_cov)):

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.

[Major / P2] Fail when measurement records are missing instead of intersecting them away

load() turns a missing COVERAGE.tsv into {}, and this intersection drops every file missing from either side. Because the shell wrapper ignores run.sh failures, a startup/selection failure before coverage is written therefore reports vm_compare: 0 files -- VM_ONLY 0, EVAL_ONLY 0, VM_FILE 0 and exits 0. I reproduced that end to end by invoking the real shell wrapper with a nonexistent source tree and ruby/test_hash.rb: both runners reject the source, but the wrapper succeeds. An absent VM record or coverage row has the same result.

It also hides an already observed regression during confirmation: supply first-pass evaluator/VM records containing a VM_ONLY failure, then empty second-pass records to --both-times; the tool prints 1 files ... VM_ONLY 0 and exits 0, so a failed rerun is interpreted as a repaired/transient failure.

Validate a nonempty expected file inventory and required coverage for both executions and each confirmation pass, and propagate runner/comparator infrastructure errors independently of the twice-seen filtering. A failed or absent measurement must fail the gate rather than count as no difference. Add focused controls for missing first-pass records and a failed rerun after a detected VM regression.

284km added a commit that referenced this pull request Nov 25, 2026
ci-timing waits for unittest-vm too (fixes unittest-harness after #265)
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