Skip to content

Commit

Permalink
Introduce RAKUDO_GC_EVERY environment variable
Browse files Browse the repository at this point in the history
This affects whether a GC run will be forced for every N ThreadPoolScheduler
supervisor runs (which is usually at about 100/second).  A value of 1 thus
would force GC runs 100x/second, whereas a value of 100 would force a GC
run every second.

Note that for this to work, the supervisor must actually be running.
The simplest way to force that is, is doing a `start { }`.

The default for RAKUDO_GC_EVERY is effectively to never do an additional
GC run.

One could think about starting the supervisor automatically if
RAKUDO_GC_EVERY is explicitely specified.
  • Loading branch information
lizmat committed Nov 6, 2022
1 parent 64f552f commit 8c787d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core.c/ThreadPoolScheduler.pm6
Expand Up @@ -596,6 +596,9 @@ my class ThreadPoolScheduler does Scheduler {
my num $per-core;
my num $per-core-util;
my num $smooth-per-core-util = 0e0;
my int $ticks;
my int $gc-every =
(%*ENV<RAKUDO_GC_EVERY> // 0x7fffffffffffffff).Int;

scheduler-debug "Supervisor thinks there are $cpu-cores CPU cores";
loop {
Expand All @@ -612,6 +615,7 @@ my class ThreadPoolScheduler does Scheduler {
# Wait until the next time we should check how things
# are.
nqp::sleep(SUPERVISION_INTERVAL);
nqp::force_gc() unless nqp::mod_i(++$ticks,$gc-every);

# Work out the delta of CPU usage since last supervision
# and the time period that measurement spans.
Expand Down

0 comments on commit 8c787d1

Please sign in to comment.