[sgen] Trim worker gray queue after finishing concurrent mark
authorVlad Brezae <brezaevlad@gmail.com>
Tue, 13 Sep 2016 20:04:40 +0000 (23:04 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Fri, 16 Sep 2016 17:45:14 +0000 (20:45 +0300)
This was keeping around potentially many unused gray queue sections, or even constantly leaking in the case of many majors since every time we start a concurrent major we redirect some additional gray queue sections from main to worker thread gray queues, leading to unbounded growth. The gc thread always trims its gray queues at the end of the collection.

On graph8 this reduces memory usage by 5%. Fixes mem leak from #41995

mono/sgen/sgen-workers.c

index dfdff8c9062f2a7e25f8b5d5591ebc1b1b598187..76eebdd86edfe066f5bfbdf1c6c51d6ad562372e 100644 (file)
@@ -97,7 +97,7 @@ sgen_workers_ensure_awake (void)
 }
 
 static void
-worker_try_finish (void)
+worker_try_finish (WorkerData *data)
 {
        State old_state;
 
@@ -115,6 +115,8 @@ worker_try_finish (void)
        } while (!set_state (old_state, STATE_NOT_WORKING));
 
        binary_protocol_worker_finish (sgen_timestamp (), forced_stop);
+
+       sgen_gray_object_queue_trim_free_list (&data->private_gray_queue);
 }
 
 void
@@ -226,7 +228,7 @@ marker_idle_func (void *data_untyped)
                        sgen_thread_pool_job_enqueue (job);
                        preclean_job = NULL;
                } else {
-                       worker_try_finish ();
+                       worker_try_finish (data);
                }
        }
 }