summaryrefslogtreecommitdiff
path: root/mjit_worker.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-05-02 21:30:24 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2020-05-02 21:43:28 -0700
commitcc6afff006760768feed4d2646a9af1dede4fca6 (patch)
treed223bde9a0ba49b8f2e7c60bfccf75339de35537 /mjit_worker.c
parent224f29c8e92094af10bc666c474b81a3545d6adf (diff)
Avoid infinite times of JIT compaction
It's to avoid memory leak for actual usage (because they don't get unloaded properly), but also for fixing CI timed out due to JIT compaction taking too long time on --jit-wait (which runs every time) http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2911601
Diffstat (limited to 'mjit_worker.c')
-rw-r--r--mjit_worker.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/mjit_worker.c b/mjit_worker.c
index 037aa29..f479844 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -1303,6 +1303,11 @@ mjit_copy_cache_from_main_thread(const rb_iseq_t *iseq, union iseq_inline_storag
void
mjit_worker(void)
{
+ // Allow only `max_cache_size / 10` times (default: 10) of compaction.
+ // Note: GC of compacted code has not been implemented yet.
+ int max_compact_size = mjit_opts.max_cache_size / 10;
+ if (max_compact_size < 10) max_compact_size = 10;
+
#ifndef _MSC_VER
if (pch_status == PCH_NOT_READY) {
make_pch();
@@ -1354,9 +1359,10 @@ mjit_worker(void)
CRITICAL_SECTION_FINISH(3, "in jit func replace");
#ifndef _MSC_VER
- // Combine .o files to one .so and reload all jit_func to improve memory locality
- if ((!mjit_opts.wait && unit_queue.length == 0 && active_units.length > 1)
- || active_units.length == mjit_opts.max_cache_size) {
+ // Combine .o files to one .so and reload all jit_func to improve memory locality.
+ if (compact_units.length < max_compact_size
+ && ((!mjit_opts.wait && unit_queue.length == 0 && active_units.length > 1)
+ || active_units.length == mjit_opts.max_cache_size)) {
compact_all_jit_code();
}
#endif