diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-05-17 19:18:42 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-10-22 12:18:39 -0400 |
commit | b967e470d806656b0f751d40884ae7edfeaa534c (patch) | |
tree | 5c6ce9e769596b6971707915708dbc534aed9c97 /rts/sm/GC.c | |
parent | 53a1a27e51f978f520b6084aff2e4b25014b5cf3 (diff) | |
download | haskell-b967e470d806656b0f751d40884ae7edfeaa534c.tar.gz |
NonMoving: Don't do major GC if one is already running
Previously we would perform a preparatory moving collection, resulting
in many things being added to the mark queue. When we finished with this
we would realize in nonmovingCollect that there was already a collection
running, in which case we would simply not run the nonmoving collector.
However, it was very easy to end up in a "treadmilling" situation: all
subsequent GC following the first failed major GC would be scheduled as
major GCs. Consequently we would continuously feed the concurrent
collector with more mark queue entries and it would never finish.
This patch aborts the major collection far earlier, meaning that we
avoid adding nonmoving objects to the mark queue and allowing the
concurrent collector to finish.
Diffstat (limited to 'rts/sm/GC.c')
-rw-r--r-- | rts/sm/GC.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c index a97042c718..6be81e5ff0 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -268,6 +268,18 @@ GarbageCollect (uint32_t collect_gen, /* See Note [Deadlock detection under nonmoving collector]. */ deadlock_detect_gc = deadlock_detect; +#if defined(THREADED_RTS) + if (major_gc && RtsFlags.GcFlags.useNonmoving && concurrent_coll_running) { + /* If there is already a concurrent major collection running then + * there is no benefit to starting another. + * TODO: Catch heap-size runaway. + */ + N--; + collect_gen--; + major_gc = false; + } +#endif + /* N.B. The nonmoving collector works a bit differently. See * Note [Static objects under the nonmoving collector]. */ |