From: takashikkbn@... Date: 2018-10-28T00:32:33+00:00 Subject: [ruby-core:89586] [Ruby trunk Bug#14867] Process.wait can wait for MJIT compiler process Issue #14867 has been updated by k0kubun (Takashi Kokubun). > I haven't looked at it in detail, but it adds extra synchronization overhead for a slightly more up-to-date cache, right? Correct. > Back-and-forth synchronization between threads kills parallelism and likely defeats the purpose of MJIT worker having its own thread. This part may not be correct. The introduction of synchronization did not spoil the benchmark result of Optcarrot. I assume that this is because RUBY_VM_CHECK_INTS calls are frequent enough (MJIT worker is not waiting for a long time), copy job (2 memcpy calls) is fast enough, and the time taken for compilation by C compiler is much longer than the time until being enqueued so that necessary caches are filled until being JIT-ed. > 1. Copy cache when enqueueing during mjit_add_iseq_to_process, give up on up-to-dateness of IC/CC. This should be easy and simplify existing code, even. I agree that it's worth experimenting with, and actually I tried the approach first. Unfortunately it didn't work well at least for Optcarrot because its hotspot requires a lot of calls to fill inline caches to reproduce the current benchmark result. Requiring 100,000 calls to enqueue doesn't work for Optcarrot because it renders a lot of pixels even in the first frame. We're not sure if the workload is so common, but having the latest cache is desired if possible. But still this would be the simplest approach for this issue. > 2. Get rid of MJIT worker thread and rely on SIGCHLD + non-blocking waitpid. I don't know the portability problems in Windows, though. It sounds interesting and it could be reasonable since the major time of JIT is taken for waiting for C compiler process. But we already achieved a complete support of mswin MJIT and I'm reluctant to reduce the portability. ---------------------------------------- Bug #14867: Process.wait can wait for MJIT compiler process https://bugs.ruby-lang.org/issues/14867#change-74626 * Author: k0kubun (Takashi Kokubun) * Status: Assigned * Priority: Normal * Assignee: k0kubun (Takashi Kokubun) * Target version: * ruby -v: * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- If Ruby tries to wait for any child process, MJIT's gcc/clang process could be caught by the method call. It's not convenient for both Ruby's user and MJIT worker thread, so Process.wait and its families should somehow avoid waiting for it. ---Files-------------------------------- 0001-hijack-SIGCHLD-handler-for-internal-use.patch (13.8 KB) JIT-test-all.log (39.9 KB) mjit_test-all_63796.log (40.4 KB) config_ruby-loco_mingw.log (27 KB) test_jit_results.txt (41.2 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: