From 5d80d08b8c2327752d9b68ba0c4723ce9a76a40e Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Wed, 29 Mar 2017 00:12:02 +0300 Subject: [PATCH] [sgen] Increase gray stack section size Stealing a gray section is relatively expensive since it requires locking. We want to avoid repeated stealing, since only one gray queue section is stolen at a time (in the case of the parallel collector). --- mono/sgen/sgen-gray.h | 2 +- mono/sgen/sgen-workers.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mono/sgen/sgen-gray.h b/mono/sgen/sgen-gray.h index bbaefe07575..3ea4037af24 100644 --- a/mono/sgen/sgen-gray.h +++ b/mono/sgen/sgen-gray.h @@ -47,7 +47,7 @@ #define SGEN_GRAY_QUEUE_HEADER_SIZE 3 #endif -#define SGEN_GRAY_QUEUE_SECTION_SIZE (128 - SGEN_GRAY_QUEUE_HEADER_SIZE) +#define SGEN_GRAY_QUEUE_SECTION_SIZE (512 - SGEN_GRAY_QUEUE_HEADER_SIZE) #ifdef SGEN_CHECK_GRAY_OBJECT_SECTIONS typedef enum { diff --git a/mono/sgen/sgen-workers.c b/mono/sgen/sgen-workers.c index e1633f3f4cc..d5343db50d1 100644 --- a/mono/sgen/sgen-workers.c +++ b/mono/sgen/sgen-workers.c @@ -61,6 +61,8 @@ enum { STATE_WORK_ENQUEUED }; +#define SGEN_WORKER_MIN_SECTIONS_SIGNAL 4 + typedef gint32 State; static SgenObjectOperations * volatile idle_func_object_ops; @@ -330,7 +332,8 @@ marker_idle_func (void *data_untyped) sgen_drain_gray_stack (ctx); - if (data->private_gray_queue.num_sections > 16 && workers_finished && worker_awakenings < active_workers_num) { + if (data->private_gray_queue.num_sections >= SGEN_WORKER_MIN_SECTIONS_SIGNAL + && workers_finished && worker_awakenings < active_workers_num) { /* We bound the number of worker awakenings just to be sure */ worker_awakenings++; mono_os_mutex_lock (&finished_lock); -- 2.25.1