Skip to content

CI checks of the ISeq VM: the fallbacks held to a list, the forced VM, the compilers' chain - #261

Merged
284km merged 1 commit into
mainfrom
stage10-vm-ci-gates
Nov 25, 2026
Merged

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

Conversation

@284km

@284km 284km commented Nov 25, 2026

Copy link
Copy Markdown
Owner

#232's first three checks for CI, as the owner decided, and a fourth found on the way. This changes .github/workflows/ci.yml: the owner reviews it before it is merged.

Built on #257 (round 65), which regenerates the embedded copy of the Ruby compiler that one of the new steps checks. The PR's base is #257's branch, so the diff here is this change alone; it is retargeted to main when #257 is merged.

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

#232 proposed four checks CI did not make of the VM; the owner decided to take the first three now. This is those three, and a fourth found while writing them.

1. A list of fallbacks

tools/iseq/vm_corpus.sh already ran in CI, on macOS and Linux, and failed on a program whose output under MERE_RUBY_VM differs from ruby's. A program the VM declined ran on the evaluator, matched, and passed as a "fallback".

It is now held to tools/iseq/vm_fallbacks.txt, a list in the repository: one program a line and why. The script fails

  • when a program falls back that is not listed: "UNLISTED fallback corpus/NNN_x.rb (why): the VM declines a program it is not listed to decline";
  • when a listed program runs on the VM: "LISTED but on the VM: ... remove its line".

Only the programs of the run are held to the list, so a run over a few files works as before. VM_FALLBACKS=<file> names another list and VM_FALLBACKS=none none.

The list is empty: since round 63 (#233) every corpus program runs on the VM. Adding a line is a change a PR has to make, and say why.

How it was checked, on this branch:

the run exit
a program with a BEGIN block added (the VM declines it), not listed "UNLISTED fallback ... (a BEGIN block)" 1
the same, with a list naming it passes 0
a list naming corpus 801, which runs on the VM "LISTED but on the VM: corpus/801_... runs on the VM now" 1
VM_FALLBACKS=none passes 0

The files a program requires are not held to a list yet (MERE_RUBY_VM=report names those): the owner put that later.

2. The forced VM

A step runs tools/iseq/vm_check.sh: 245 snippets through RubyVM::InstructionSequence#eval with the VM forced, each compared with ruby, stdout and stderr. A snippet the VM declines fails here.

3. The compilers' chain

What runs on the VM is the native compiler's sequence. That it is ruby's rests on two comparisons, made by hand until now:

  • the Ruby compiler (lib/iseq_compiler_ext.rb) against ruby's own #to_a: compare_with_ruby.rb over the 460 snippets and compare_files.rb over the whole corpus;
  • the native compiler against the Ruby one: tools/iseq/native/check.sh over the whole corpus.

One step runs the three. A file that differs fails it; a file one of them declines is counted and passes, being the list of fallbacks' business when the VM declines it.

compare_with_ruby.rb exited 0 whatever it found; it exits 1 when a snippet differs now, and writes its two files in a directory of its own.

4. The embedded copy of the Ruby compiler

Writing these, it showed that mere-ruby's copy of the Ruby compiler was stale. mere-ruby carries it as a string in m_pathname_lib.mere, made from the lib by tools/gen_pathname_lib.rb. Round 63 (#233) changed the lib and not the copy, and the comparisons above, which read the lib, could not see it.

A step generates the file again and compares it, as the job does for the Psych and network libraries. It fails on main as it was: the regeneration is in round 65's PR (#257), which this one is built on.

Times

Here, each step run alone at a load of 25 to 35 (other sessions' work), on main 323706a with #257:

step here
vm_corpus.sh -j 3 with the list (it ran before; the list costs nothing) 5 min 39 s
vm_check.sh 2 min 1 s
compare_with_ruby.rb (460 snippets) 1 s
compare_files.rb (893 files) 8 s
native/check.sh (893 files) 1 min 2 s
gen_pathname_lib.rb and cmp 1 s

CI's own times are added below when this PR's run is through.

Checked

Against ruby 4.0.10 (tools/ref_ruby.sh), built with Mere 9dec2ff6, on main 323706a with #257:

  • every step above passes, with the numbers in its table: 893 programs on the VM and none against the list; vm_check 245/245; 460 snippets; 893 files the same in each comparison, none refused; the embedded copy as generated.
  • the list check fails and passes as the first table says.
  • With the Ruby compiler made wrong on purpose (a nil pushed with putobject instead of putnil), compare_with_ruby.rb exits 1 (400 snippets the same, 60 different), and so does compare_files.rb over the first nine corpus programs (2 different).

🤖 Generated with Claude Code

…, the compilers' chain

#232's first three proposals, as the owner decided. vm_corpus.sh holds each
program that falls back to tools/iseq/vm_fallbacks.txt (empty): one not
listed fails, and so does one listed that runs on the VM. The corpus job
runs vm_check.sh, and the compilers' comparisons over the whole corpus:
compare_with_ruby.rb and compare_files.rb (the Ruby compiler against ruby),
native/check.sh (the native compiler against the Ruby one). And it checks
that m_pathname_lib.mere, the embedded copy of the Ruby compiler, is as
generated. compare_with_ruby.rb exits 1 when a snippet differs.
@284km
284km changed the base branch from stage10-r65 to main November 25, 2026 01:44

@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 f6cb33e. No Critical / Major / Minor findings. This PR edits .github/workflows/ci.yml, so the owner reviews and merges it. The base is still stage10-r65 (#257, now merged); retarget it to main first.

  • vm_corpus.sh against a list of fallbacks (tools/iseq/vm_fallbacks.txt, empty since #233):
    • an unlisted fallback fails the run, and so does a listed program that now runs on the VM;
    • only the programs of the run are checked, so a subset run behaves as before;
    • VM_FALLBACKS=none opts out;
    • the description's table shows both failure directions and the listed-and-passing case.
  • New CI steps in the corpus job:
    • vm_check.sh (VM forced);
    • compare_with_ruby.rb over the 460 snippets (it now exits 1 on a difference, and writes its diff inputs to a private Dir.mktmpdir instead of fixed /tmp/ma.txt / ra.txt);
    • compare_files.rb and native/check.sh over the whole corpus;
    • a cmp of m_pathname_lib.mere against tools/gen_pathname_lib.rb's fresh output, which would have caught round 63's stale embedded compiler.
  • Local times (load 25–35): vm_check about 2 min, native/check about 1 min, the rest seconds. Please add the CI times when the run finishes.
  • Cosmetic only: ${nlist:+…} always expands, because nlist is always set (to 0), so the summary line always ends with ", 0 against the list of fallbacks". Harmless.
  • No mere-pr-review-watch inline comments.

@284km
284km merged commit 9d1948f into main Nov 25, 2026
9 of 19 checks passed
284km added a commit that referenced this pull request Nov 25, 2026
vm_check.sh: the ruby on PATH when the rbenv build is not there (fixes #261's CI step)
@284km

284km commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Step times of the four ISeq VM steps, from the first run after #296 where vm_check and the two steps after it ran to the end (run 45665012046, branch rails-ar-ivar-walks, corpus job):

step result time
Compare every corpus program on the ISeq VM success 2 min 59 s
Compare the forced ISeq VM with ruby (vm_check) success 1 min 6 s
Compare the ISeq compilers with ruby and with each other success 27 s
Check the embedded ISeq compiler and the other embedded libraries are current success under 1 s

Together about 4 min 32 s of the corpus job.

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