From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-developers@cygwin.com
Subject: Re: load average calculation failing -- fixed by Windows update
Date: Tue, 17 May 2022 15:48:26 +0100 [thread overview]
Message-ID: <af45b08a-6979-33d2-2543-d570ff7a5a56@dronecode.org.uk> (raw)
In-Reply-To: <Yn47gb2o07WjnDlk@calimero.vinschen.de>
On 13/05/2022 12:05, Corinna Vinschen wrote:
> On May 13 13:04, Corinna Vinschen wrote:
>> On May 13 11:34, Jon Turney wrote:
>>> On 12/05/2022 10:48, Corinna Vinschen wrote:
>>>> On May 11 16:40, Mark Geisert wrote:
>>>>>
>>>>> The first counter read now gets error 0xC0000BC6 == PDH_INVALID_DATA, but no
>>>>> errors on subsequent counter reads. This sounds like it now matches what
>>>>> Corinna reported for W11. I wonder if she's running build 1706 already.
>>>>
>>>> Erm... looks like I didn't read your mail throughly enough.
>>>>
>>>> This behaviour, the first call returning with PDH_INVALID_DATA and only
>>>> subsequent calls returning valid(?) values, is what breaks the
>>>> getloadavg function and, consequentially, /proc/loadavg. So maybe xload
>>>> now works, but Cygwin is still broken.
>>>
>>> The first attempt to read '% Processor Time' is expected to fail with
>>> PDH_INVALID_DATA, since it doesn't have a value at a particular instant, but
>>> one averaged over a period of time.
>>>
>>> This is what the following comment is meant to record:
>>>
>>> "Note that PDH will only return data for '% Processor Time' after the second
>>> call to PdhCollectQueryData(), as it's computed over an interval, so the
>>> first attempt to estimate load will fail and 0.0 will be returned."
>>
>> But.
>>
>> Every invocation of getloadavg() returns 0. Even under load. Calling
>> `cat /proc/loadavg' is an excercise in futility.
>>
>> The only way to make getloadavg() work is to call it in a loop from the
>> same process with a 1 sec pause between invocations. In that case, even
>> a parallel `cat /proc/loadavg' shows the same load values.
>>
>> However, as soon as I stop the looping process, the /proc/loadavg values
>> are frozen in the last state they had when stopping that process.
>
> Oh, and, stopping and restarting all Cygwin processes in the session will
> reset the loadavg to 0.
>
>> Any suggestions how to fix this?
Ah, right. 'while true ; do cat /proc/loadavg ; done', just shows a
stream of zeroes, because each process only calls getloadavg() once,
which doesn't update the loadavg, because the first call to fetch it
fails PDH_INVALID_DATA.
This isn't really simply fixable because PDH "handles" aren't shareable
between processes.
I don't think this is new since it is mentioned in [1].
Non-solution: use top instead :)
[1] https://cygwin.com/pipermail/cygwin-patches/2017q1/008699.html
next prev parent reply other threads:[~2022-05-17 14:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.BSF.4.63.2205051618470.42373@m0.truegem.net>
2022-05-08 7:01 ` load average calculation failing Mark Geisert
[not found] ` <223aa826-7bf9-281a-aed8-e16349de5b96@dronecode.org.uk>
2022-05-09 8:45 ` Corinna Vinschen
2022-05-09 8:53 ` Corinna Vinschen
2022-05-10 8:34 ` Mark Geisert
2022-05-10 13:37 ` Jon Turney
2022-05-11 23:40 ` load average calculation failing -- fixed by Windows update Mark Geisert
2022-05-12 8:17 ` Corinna Vinschen
2022-05-12 8:24 ` Mark Geisert
2022-05-12 8:43 ` Corinna Vinschen
2022-05-12 9:48 ` Corinna Vinschen
2022-05-13 10:34 ` Jon Turney
2022-05-13 11:04 ` Corinna Vinschen
2022-05-13 11:05 ` Corinna Vinschen
2022-05-16 5:25 ` load average calculation imperfections Mark Geisert
2022-05-16 16:49 ` Jon Turney
2022-05-17 5:39 ` Mark Geisert
2022-05-17 14:48 ` Jon Turney [this message]
2022-05-17 19:48 ` load average calculation failing -- fixed by Windows update Mark Geisert
2022-05-09 11:29 ` load average calculation failing Jon Turney
2022-05-10 8:21 ` Mark Geisert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=af45b08a-6979-33d2-2543-d570ff7a5a56@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-developers@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).