@@ -47,7 +47,7 @@ unsigned volatile int current_threads_spinning = 0; // The number of threads cur
47
47
#define WORKER_IDLE_SECONDS_THRESHOLD 15
48
48
49
49
/* Function prototypes */
50
- static unsigned int get_load_average (void );
50
+ static unsigned int get_runqueue_length (void );
51
51
static void * worker_main (void * arg );
52
52
static void * overcommit_worker_main (void * arg );
53
53
static unsigned int get_process_limit (void );
@@ -75,7 +75,7 @@ static int wqlist_has_manager;
75
75
static pthread_attr_t detached_attr ;
76
76
77
77
static struct {
78
- volatile unsigned int load ,
78
+ volatile unsigned int runqueue_length ,
79
79
count ,
80
80
idle ;
81
81
sem_t sb_sem ;
@@ -482,7 +482,7 @@ worker_stop(void)
482
482
static void *
483
483
manager_main (void * unused __attribute__ ((unused )))
484
484
{
485
- unsigned int load_max = ( cpu_count + 1 ); // We allow +1 to take manager thread into account
485
+ unsigned int runqueue_length_max = cpu_count ;
486
486
unsigned int worker_max , current_thread_count = 0 ;
487
487
unsigned int worker_idle_seconds_accumulated = 0 ;
488
488
unsigned int max_threads_to_stop = 0 ;
@@ -493,7 +493,7 @@ manager_main(void *unused __attribute__ ((unused)))
493
493
struct timeval tp ;
494
494
495
495
worker_max = get_process_limit ();
496
- scoreboard .load = get_load_average ();
496
+ scoreboard .runqueue_length = get_runqueue_length ();
497
497
498
498
/* Block all signals */
499
499
sigfillset (& sigmask );
@@ -532,27 +532,27 @@ manager_main(void *unused __attribute__ ((unused)))
532
532
// If no workers available, check if we should create a new one
533
533
if ((scoreboard .idle == 0 ) && (scoreboard .count > 0 ) && (pending_thread_create == 0 )) // last part required for an extremely unlikely race at startup
534
534
{
535
- // allow cheap rampup up to worker_idle_threshold without going to /proc / checking load average
535
+ // allow cheap rampup up to worker_idle_threshold without going to /proc / checking run queue length
536
536
if (scoreboard .count < worker_idle_threshold )
537
537
{
538
538
worker_start ();
539
539
}
540
540
else
541
541
{
542
- // otherwise check if load / stalled threads allows for new creation unless we hit worker_max ceiling
542
+ // otherwise check if run queue length / stalled threads allows for new creation unless we hit worker_max ceiling
543
543
544
544
if (scoreboard .count < worker_max )
545
545
{
546
546
if (threads_runnable (& current_thread_count ) != 0 )
547
547
current_thread_count = 0 ;
548
548
549
- // only start thread if we have less runnable threads than cpus and load allows it
549
+ // only start thread if we have less runnable threads than cpus and run queue length allows it
550
550
551
551
if (current_thread_count <= cpu_count ) // <= discounts the manager thread
552
552
{
553
- scoreboard .load = get_load_average ();
553
+ scoreboard .runqueue_length = get_runqueue_length ();
554
554
555
- if (scoreboard .load <= load_max ) // <= discounts the manager thread
555
+ if (scoreboard .runqueue_length <= runqueue_length_max ) // <= discounts the manager thread
556
556
{
557
557
if (scoreboard .idle == 0 ) // someone might have become idle during getting thread count etc.
558
558
worker_start ();
@@ -562,8 +562,8 @@ manager_main(void *unused __attribute__ ((unused)))
562
562
}
563
563
else
564
564
{
565
- dbg_printf ("Not spawning worker thread, scoreboard.load = %d > load_max = %d" ,
566
- scoreboard .load , load_max );
565
+ dbg_printf ("Not spawning worker thread, scoreboard.runqueue_length = %d > runqueue_length_max = %d" ,
566
+ scoreboard .runqueue_length , runqueue_length_max );
567
567
}
568
568
}
569
569
else
@@ -731,7 +731,7 @@ get_process_limit(void)
731
731
}
732
732
733
733
static unsigned int
734
- get_load_average (void )
734
+ get_runqueue_length (void )
735
735
{
736
736
double loadavg ;
737
737
@@ -744,7 +744,7 @@ get_load_average(void)
744
744
return solaris_get_runqueue_length ();
745
745
#endif
746
746
747
- /* Fallback to using the 1-minute load average. */
747
+ /* Fallback to using the 1-minute load average if proper run queue length can't be determined . */
748
748
749
749
/* TODO: proper error handling */
750
750
if (getloadavg (& loadavg , 1 ) != 1 ) {
0 commit comments