[ruby-core:109586] [Ruby master Misc#18968] Run MJIT under a forked Ruby process
From:
"chrisseaton (Chris Seaton)" <noreply@...>
Date:
2022-08-20 10:08:02 UTC
List:
ruby-core #109586
Issue #18968 has been updated by chrisseaton (Chris Seaton). An interesting project if you are changing the interface could be to write a generic JIT interface, which any JIT could plug into. At the moment we have custom C code to plug in MJIT and YJIT - an interface could reduce that C code and enable more experimentation with JITs. In Java, this is called JVMCI - the JVM Compiler Interface. https://openjdk.org/jeps/243 ---------------------------------------- Misc #18968: Run MJIT under a forked Ruby process https://bugs.ruby-lang.org/issues/18968#change-98761 * Author: k0kubun (Takashi Kokubun) * Status: Open * Priority: Normal ---------------------------------------- # Changes * When MJIT compiles a method, it spawns a child Ruby process and lets it generate a C code and compile it. * Stop supporting platforms without fork(2), i.e. mswin * A suggested alternative to it in Windows, in general, is running the implementation for Linux on WSL. It's likely already faster than the mswin one because of recent SIGCHLD-related changes. # Background To improve the maintainability of MJIT's optimization logic, I'm planning to rewrite MJIT in Ruby. To run Ruby code safely, you need a GVL or at least be on a Ractor. Doing so in the main thread would cause performance problems. We evaluated running MJIT on a Ractor https://github.com/ruby/ruby/pull/4024, but enabling the multi-Ractor mode slows down things. The proposed change, forking a child process, doesn't enable the multi-Ractor mode, and it's confirmed to be faster than the Ractor-based patch. If you fork a process and run it for a while, you need inter-process communication to give the latest inline cache contents. But it requires synchronization. Another option that doesn't require synchronization that much is to fork a process every time, which is what's discussed in this ticket. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>