aboutsummaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-03-19 18:32:34 +0000
committerMichael Williamson <mike@zwobble.org>2024-03-19 18:32:34 +0000
commit55349d1038858afc40f543873aae124d1f6263a8 (patch)
tree7c062f1720a934ead36df9a12bcdfe099f6c25f5 /runtime/src
parent0908a609fc1ad35308796b0bad1e05d37bfdb331 (diff)
Allow configuration of collect interval
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/shed/gc/mark-and-sweep/gc.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/runtime/src/shed/gc/mark-and-sweep/gc.c b/runtime/src/shed/gc/mark-and-sweep/gc.c
index 40ffa98b..68f9ad8e 100644
--- a/runtime/src/shed/gc/mark-and-sweep/gc.c
+++ b/runtime/src/shed/gc/mark-and-sweep/gc.c
@@ -81,13 +81,20 @@ void sweep() {
}
}
+const int collect_interval = SHED_GC_COLLECT_INTERVAL;
+
+int calls_until_next_collect = collect_interval;
+
void shed__runtime__gc_collect() {
- // We only want to collect periodically, but we currently always collect to
- // hopefully surface errors more quickly.
+ if (calls_until_next_collect == 0) {
+ calls_until_next_collect = collect_interval;
- alternate_mark_value();
+ alternate_mark_value();
- mark_reachable();
+ mark_reachable();
- sweep();
+ sweep();
+ } else {
+ calls_until_next_collect--;
+ }
}