[PATCH] Cygwin: Minor updates to load average calculations

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Wed Oct 9 16:36:03 GMT 2024


Clarity suggestions and questions that could perhaps benefit from more comment:

On 2024-10-08 23:19, Mark Geisert wrote:

>   winsup/cygwin/loadavg.cc | 55 ++++++++++++++++++++++++++++------------
>   1 file changed, 39 insertions(+), 16 deletions(-)
> 
> diff --git a/winsup/cygwin/loadavg.cc b/winsup/cygwin/loadavg.cc
> index 127591a2e..8e82b3cbd 100644
> --- a/winsup/cygwin/loadavg.cc
> +++ b/winsup/cygwin/loadavg.cc
> @@ -16,16 +16,23 @@

>     The number of running processes is estimated as (NumberOfProcessors) * (%
> -  Processor Time).  The number of runnable processes is estimated as
> -  ProcessorQueueLength.
> +  Processor Time).  The number of runnable threads is estimated as

This looks weird with arbitrary split then indentation; maybe move at least "(%" 
to next line, maybe also "*", or the whole expression, and maybe add semantic 
newlines after the sentences:

 >   The number of running processes is estimated as NumberOfProcessors *
 >   % Processor Time.  The number of runnable threads is estimated as

 >   The number of running processes is estimated as
 > 	NumberOfProcessors * % Processor Time.
 >   The number of runnable threads is estimated as
 >	ProcessorQueueLength / NumberOfProcessors.
 >   The instantaneous load ...

> +  (ProcessorQueueLength) / (NumberOfProcessors).  The "instantaneous" load
> +  estimate is taken to be the sum of those two numbers.

Which two are the values summed: running processes + runnable threads?

> @@ -62,31 +69,46 @@ static bool load_init (void)
  +    Sleep (15); /* let other procs run; multiple yield()s aren't enough */

Why so long - why not clock_/nanosleep for just a 16ms tick or even 1ms, as when 
system has 1ms multimedia timer ticks enabled by e.g. javascript or ntpd, or 
possibly set <1ms by some games? Effects on other processes may vary by version.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


More information about the Cygwin-patches mailing list