[sgen] Avoid waiting for workers to report their own finish
authorVlad Brezae <brezaevlad@gmail.com>
Tue, 27 Jun 2017 22:41:22 +0000 (01:41 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Thu, 20 Jul 2017 10:53:43 +0000 (13:53 +0300)
commitf7cf1b7e07ff3ca9cfe2954a8c788d45c0d5ef3a
tree99095155fad402082d2a0f67adc81a7b1ae09aa5
parent5599130b36917ec7f5cc9a5c755a4f441a65efa0
[sgen] Avoid waiting for workers to report their own finish

If a worker is stuck doing work in another context, it might not be very responsive in transitioning its own state from WORK_ENQUEUED to WORKING and finally to FINISHING. When joining worker threads, we check whether we have any threads working in the corresponding context and, if there aren't any, change their state directly from the gc thread.

We can do this because work is distributed from centralized pools (worker_distribute_gray_queue and the job_queue), instead of per worker. Therefore we don't need all the workers to perform actual work in the context.
mono/sgen/sgen-thread-pool.c
mono/sgen/sgen-thread-pool.h
mono/sgen/sgen-workers.c