Allow workitems to startup faster and reduce polling thread interval in the threadpool.
authorPaolo Molaro <lupus@oddwiz.org>
Tue, 24 Sep 2013 13:25:53 +0000 (15:25 +0200)
committerPaolo Molaro <lupus@oddwiz.org>
Tue, 24 Sep 2013 13:30:51 +0000 (15:30 +0200)
Deals with xambug #14644 and similar issues.

mono/metadata/threadpool.c

index 8710dafd661e8d26ac41f99ec451bd617400a474..438713c2bffdf5187e6b298756861df00efc623c 100644 (file)
@@ -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);
 }