Skip to content

Design memo: what CI checks of the ISeq VM, and four checks it lacks - #232

Merged
284km merged 1 commit into
mainfrom
stage10-vm-ci-design
Nov 24, 2026
Merged

284km merged 1 commit into
mainfrom
stage10-vm-ci-design

Conversation

@284km

@284km 284km commented Nov 24, 2026

Copy link
Copy Markdown
Owner

A design memo only: no code and no change to CI. It answers the request for a note on CI checks of the VM before the VM is made the default (note 558, item 1). The first finding is that CI already runs the corpus on the VM; the memo is about the four checks it lacks, what each costs (measured), and what each would have caught. Each proposal would be a PR to .github/workflows/ci.yml, for the owner to decide.

The memo is loop/2026-11-25-stage10-vm-ci-design.md; what follows is it.

A memo, with no change to the code or to CI. It is for the decision on making the VM the default execution (note 558, item 1): which checks should be in CI before that, what each costs, and what each would have caught. Each proposal below changes .github/workflows/ci.yml, so each is a PR of its own for the owner to read.

What CI checks today

The corpus job (macOS) and the Linux job both run tools/iseq/vm_corpus.sh: every corpus program under MERE_RUBY_VM=1, its output and exit status compared with ruby's. A program that differs fails the job.

That is the whole of it. A program the VM declines runs on the evaluator, matches ruby, and is counted as a fallback and passed.

What that leaves open

1. A program that stops running on the VM. A change that makes the native compiler or the loader decline something it took yesterday turns programs into fallbacks, and the job stays green. The number is printed and nobody is asked to read it. The same is so of a required file: vm_corpus.sh asks only of the main script.

2. The VM forced. tools/iseq/vm_check.sh runs 245 snippets through RubyVM::InstructionSequence#eval with the VM forced, and compares each byte with ruby. Forced means a refusal is a failure, so it is the one check where "the VM does not take this" is red. It is not in CI.

3. The two compilers against each other. tools/iseq/native/check.sh compiles a file with the native compiler and with the Ruby one, and compares the two trees as text. The native compiler is the one that runs; the Ruby one is the one whose output was compared with ruby's own #to_a (tools/iseq/compare_with_ruby.rb, compare_files.rb). Neither comparison is in CI. A change to ic/ is checked in CI only by what the corpus happens to run.

4. CRuby's own tests on the VM. The unit-test shards run on the evaluator. Nothing in CI runs a test file under MERE_RUBY_VM.

The four checks

Times are this machine's, each command run alone on main with #231, and CI's runners are slower.

1. A budget of fallbacks

vm_corpus.sh fails when a program falls back that is not on a list kept in the repository.

  • The list is a file, tools/iseq/vm_fallbacks.txt: one corpus program a line, with the reason as vm_corpus.sh prints it. Today it would have one line: corpus 370, a shareable_constant_value write of a value that is not a literal (round 62, A source in another encoding runs on the VM (round 62) #231, took it from four to one).
  • A program that falls back and is not listed fails the job, with its reason. A listed program that now runs on the VM fails it too, with "remove it from the list", so the list cannot go stale.
  • Adding a line is a reviewed change, which is the point: a fallback becomes something a PR says, not something a number hides.
  • Cost: none. The verdicts are already computed.

A second part, for required files: MERE_RUBY_VM=report names each file the VM declined. One more run of the corpus under =report, with the lines collected and held to a second list, would cover what a program requires. Cost: one more VM corpus run, 2 min 20 s here at four jobs. This part could wait: round 60's sweep (every corpus program run as a required file) found no required-file difference, and the main script's verdict covers most of the compiler.

2. vm_check in the corpus job

One step: sh tools/iseq/vm_check.sh. 1 min 21 s. It needs nothing the job does not have.

3. The compilers' comparison

Two parts, and they differ in what they need.

  • tools/iseq/native/check.sh over a fixed list of files (the corpus, or a sample of it, and lib/): it builds a small tool from ic/ with the Mere compiler and runs the Ruby compiler on mere-ruby. 41 s for the whole corpus, 873 files: 871 the same, 0 different, 1 the native compiler declines and the Ruby one compiles, 1 neither compiles. The job already has the Mere compiler.
  • compare_with_ruby.rb and compare_files.rb compare the Ruby compiler's tree with ruby's own. They run under the reference ruby, which the job has: 5 s for the whole corpus (872 the same, 1 refused), and under 1 s for the 460 snippets.

Together they close the chain: ruby's #to_a = the Ruby compiler's = the native compiler's, for the files listed.

Both are cheap enough to run over the whole corpus, which is the simplest rule: no list to keep. The verdict to fail on is "different" (and "failed"); a file one of them refuses is the fallback list's business, and the native comparison's "declined by the native compiler, compiled by the Ruby one" is a second kind of fallback worth a line there: the file still runs on the VM, at many times the cost to compile.

4. Unit tests on the VM

The largest, and the one that decides whether the default can change.

  • What exists: by hand, test/ruby's 142 files were run on both executions on 2026-11-17 (note 552, section 15): VM 9,532 passing tests, evaluator 9,545, the difference a leak check and a time limit. Since then the comparison has been made for the files a round touched (seven to fourteen a round). No test failed on the VM alone until round 62 (A source in another encoding runs on the VM (round 62) #231), where one did: a test whose file had been falling back whole.
  • A first step that costs little: one shard, on a schedule and not on every push, that runs a fixed list of test/ruby files under MERE_RUBY_VM=1 and compares each test's outcome with the evaluator's in the same build. The comparison is between the two executions, not with ruby, so it needs no baseline: a test that passes on one and not on the other is the finding. The time is not measured yet: the eight files a round usually compares (test_regexp, test_parse, test_syntax, test_eval, test_require, test_rubyoptions, test_iseq, test_exception) take about five minutes on one execution here, and all of test/ruby is to be measured when the comparison is next run in full.
  • The full form: the unit-test shards run twice, once with MERE_RUBY_VM=1. That doubles the largest part of CI (the shards have a 330-minute limit). It is what "the VM is the default" would mean in CI anyway: when the default changes, the shards run on the VM and the evaluator becomes the second run, or is dropped.

So the order proposed is: the scheduled shard now, to find what is VM-only while the evaluator is still the default; the full double run only for the PR that changes the default, to show the numbers side by side once.

Order, and what each would have caught

cost in CI would have caught
1. fallback list none a compiler refusal introduced by a change; and it names what is not checked: test_hash.rb fell back whole for one instruction, and the VM's wrong answer in it (a literal Hash's key was not the fstring, #231) went unseen until the refusal was removed
2. vm_check 1 min 21 s a refusal or a wrong answer in the forced VM (rounds 34 to 41 were built against it by hand)
3. compilers' comparison under 1 min a divergence of the native compiler from the Ruby one (50 files' worth were found by hand when ic/ was written)
4. scheduled VM unit shard not measured, on a schedule a test that fails on the VM alone

1, 2 and 3 are small and independent, and could be one PR or three. 4 needs a script in unittest/ that compares each test's outcome on the two executions; so far that comparison has been made by hand.

Recorded here, found while writing this

Under MERE_RUBY_VM a regexp literal with a warning was warned of twice, and a required file's regexp literal that did not compile ran anyway. Both were found by reading output by hand in rounds 60 and after (#223, #229), and neither by a check: the corpus compares stdout and the exit status, not stderr. A check of what a program writes to stderr, on both executions, is a fifth gap, and a wider one than the VM's.

🤖 Generated with Claude Code

No code and no change to CI. The corpus already runs on the VM in CI; what
is not checked is a program that stops running on the VM (a fallback), the
VM forced (vm_check), the two compilers against each other and against
ruby, and CRuby's own tests on the VM. Each with its measured cost.

@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 current head 82e81c2c against current main 6d39c773. Two documentation corrections are inline: the CI reference-Ruby invocation and the account of earlier VM validation.

The reviewed fallback list, including removal of obsolete entries, and the proposed per-test evaluator/VM comparison are useful ways to expose coverage loss. The current corpus checks and the 873-program / 245-VM-snippet / 460-compiler-snippet inventories agree with the memo.

Validation: inspected the complete memo, current workflows, the referenced harnesses and historical LOOP records; confirmed that runtime, build, dependency and workflow inputs are byte-identical to main; git diff --check passed. A missing-reference control for vm_check exited 1 before generating any real snippets, reproducing the startup problem described inline. This control did not execute the VM, and no full runtime suite or performance measurement was repeated for this documentation-only change.

Hosted CI remains incomplete, with running and queued jobs and downstream coverage still pending. No merge performed: the recorded hold_all_merges / new_failure_review_required remains active. The other open mere-ruby PRs (#224 and #228) are drafts; merelang/mere has no open PRs. This review does not clear historical resource failures or claim that pending CI passed.

Event: COMMENT because the authenticated account is the PR author.


### 2. vm_check in the corpus job

One step: `sh tools/iseq/vm_check.sh`. 1 min 21 s. It needs nothing the job does not have.

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] Pass the CI reference Ruby to this command. vm_check.sh defaults RUBY to $HOME/.rbenv/versions/4.0.10/bin/ruby; unlike vm_corpus.sh, it does not source tools/ref_ruby.sh. The corpus job installs Ruby through ruby/setup-ruby and does not export RUBY or create that rbenv path. Consequently, copying this proposed one-step command into that job fails during snippet generation instead of checking the VM. Please document . ./tools/ref_ruby.sh followed by RUBY="$REF_RUBY_BIN" sh tools/iseq/vm_check.sh, or include updating the script to use the repository reference selector as a prerequisite.


The largest, and the one that decides whether the default can change.

- **What exists**: by hand, test/ruby's 142 files were run on both executions on 2026-11-17 (note 552, section 15): VM 9,532 passing tests, evaluator 9,545, the difference a leak check and a time limit. Since then the comparison has been made for the files a round touched (seven to fourteen a round). No test failed on the VM alone until round 62 (#231), where one did: a test whose file had been falling back whole.

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.

[Minor] [P3] Reconcile this history with the earlier full VM CI run. LOOP.md, section "2026-11-19 (87): the VM as the default, measured over the whole suite", already records run 44295654770 on vm-default-r44, covering 758 files. It specifically records a VM-only wrong answer in TestKeyword#test_kwrest_overwritten, its fix, and VM-sensitive timeouts. This contradicts both the implication that only selected-file comparisons happened after November 17 and the statement that no test failed on the VM alone before round 62. Please include that whole-suite comparison and its limitations, and scope the no-new-failures claim to the actual later interval if that is what was intended. That history matters when deciding what evidence is still needed before changing the default.

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