From 3c347d5d3a9c58666ef33c96e28a16c751e59619 Mon Sep 17 00:00:00 2001 From: Paolo Molaro Date: Tue, 24 Sep 2013 15:25:53 +0200 Subject: [PATCH] Allow workitems to startup faster and reduce polling thread interval in the threadpool. Deals with xambug #14644 and similar issues. --- mono/metadata/threadpool.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c index 8710dafd661..438713c2bff 100644 --- a/mono/metadata/threadpool.c +++ b/mono/metadata/threadpool.c @@ -771,7 +771,7 @@ monitor_thread (gpointer unused) thread = mono_thread_internal_current (); ves_icall_System_Threading_Thread_SetName_internal (thread, mono_string_new (mono_domain_get (), "Threadpool monitor")); while (1) { - ms = 500; + ms = 2000; i = 10; //number of spurious awakes we tolerate before doing a round of rebalancing. do { guint32 ts; @@ -1041,6 +1041,7 @@ pulse_on_new_job (ThreadPool *tp) { if (tp->waiting) MONO_SEM_POST (&tp->new_job); + threadpool_start_thread (tp); } void @@ -1096,7 +1097,7 @@ threadpool_append_jobs (ThreadPool *tp, MonoObject **jobs, gint njobs) mono_cq_enqueue (tp->queue, ar); } - for (i = 0; tp->waiting > 0 && i < MIN(njobs, tp->max_threads); i++) + for (i = 0; i < MIN(njobs, tp->max_threads); i++) pulse_on_new_job (tp); } -- 2.25.1