I noticed this while running test_yjit with --mjit-call-threshold=1,
which redefines `Integer#<`. When Ruby is monkey-patched,
MJIT itself could be broken.
Similarly, Ruby scripts could break MJIT in many different ways. I
prepared the same set of hooks as YJIT so that we could possibly
override it and disable it on those moments. Every constant under
RubyVM::MJIT is private and thus it's an unsupported behavior though.
All values should have a MJIT_ prefix. We could address the warning for
the end mark if we just define the macro for the check next to the enum.
It even simplifies some code for checking the enum.
This reverts commit ccd8dd6ad3.
Revert "MJIT: Fix miniruby with MJIT_FORCE_ENABLE"
This reverts commit b033775ed9.
GitHub Actions is failing. I ran out of time today to investigate it.
will try it again tomorrow.
process. Completely isolating the MJIT compilation process complicates a
lot of things for ensuring consistency before and after the fork.
Just running this synchronously makes things a lot easier, for example
the race condition of capture_cc_entries could be fixed by this patch
alone. Hopefully, the bottleneck is the C compiler and not this Ruby
code. Also, this change doesn't negatively impact MJIT's final numbers
on yjit-bench while "1st itr" is degraded for sure.
These days we benchmark MJIT using yjit-bench. The warmup duration in
yjit-bench is very short, so compiling many methods comes at a cost even
while it's actually optimal for MJIT to compile everything / tens of
thousands of methods once it reaches the peak performance.
yjit-bench doesn't necessarily represent the peak performance on production.
It measures the performance of Ruby 30~60s after boot. If your JIT takes
more than 1 minute to warm up, there's no way for the JIT to make the numbers
good on yjit-bench.
Until we make MJIT's compilation much faster, we don't afford compiling
10,000 methods on yjit-bench.
This change alone makes MJIT's benchmark number on railsbench 2x better :p
You may use `RUBYOPT=--mjit=pause irb` to play with RubyVM::MJIT::C,
control the boot timing of MJIT, or customize the implementation while
paused. It's an undocumented feature for such experiments.
The current MJIT relies on SIGCHLD and fork(2) to be performant, and
it's something mswin can't offer. You could run Linux MJIT on WSL
instead.
[Misc #18968]