Misc #18968
Updated by k0kubun (Takashi Kokubun) over 2 years ago
# 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 a 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.