public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Mark Geisert <mark@maxrnd.com>
To: cygwin-developers@cygwin.com
Subject: Re: load average calculation failing
Date: Tue, 10 May 2022 01:34:50 -0700	[thread overview]
Message-ID: <53664601-5858-ffd5-f854-a5c10fc25613@maxrnd.com> (raw)
In-Reply-To: <YnjUxi/IsgkTInKL@calimero.vinschen.de>

Corinna Vinschen wrote:
> [redirect back to cygwin-developers]
> 
> On May  8 11:27, Jon Turney wrote:
>> On 08/05/2022 08:01, Mark Geisert wrote:
>>> Mark Geisert wrote (on the main Cygwin mailing list):
>>>> I've recently noticed that the 'xload' I routinely run shows zero
>>>> load even with compute-bound processes running.  This is on both
>>>> Cygwin pre-3.4.0 as well as 3.3.4.  A test program, shown below,
>>>> indicates that getloadavg() is returning with 0 status, i.e. not an
>>>> error but no elems
>>>> of the passed-in array updated.
>>>>
>>>> Stepping with gdb through the test program seems weird within the
>>>> loadavginfo::load_init method.  Single-stepping at line
>>>> loadavg.cc:68 goes to strace.h:52 and then to _sigbe ?!
>>>>
>>>> I had recently updated both Cygwin and Windows 10 to latest at the
>>>> same time so I cannot say when the failure started.  Last day or two
>>>> at most.
>>>>
>> [...]
>>>
>>> I've debugged a bit further..  Within Cygwin's loadavg.cc:load_init(),
>>> the PdhOpenQueryW() call returns successfully.  The subsequent
>>> PdhAddEnglishCounterW() call is unsuccessful.  It returns status
> 
> This is a bit weird.  I tried to debug this for a while on Friday on
> W11 and on W11 I can reproduce *a* problem, too, just not the same you
> report here.
> 
> On W11 I see load_init() working fine, the calls to
> PdhAddEnglishCounterW succeed.  But then the call to
> PdhGetFormattedCounterValue in get_load() fails with error
> PDH_INVALID_DATA.  The CStatus member of fmtvalue1 is set to
> PDH_CSTATUS_NO_INSTANCE.
> 
> If I tweak get_load to call PdhCollectQueryData again after a fail,
> the second call succeeds.  The only problem with this is, the returned
> data doesn't make a lot of sense. It only starts to make sense if I
> add a Sleep(1000) before the second PdhCollectQueryData call, which is
> rather disappointing.
> 
> Jon, would it, perhaps, make sense to call PdhCollectQueryData in
> load_init(), without actually checking the return value?  The idea is,
> to make sure to have a base for the next call to PdhCollectQueryData
> from inside load_init.
> 
> But even then, the first values returned by getloadavg might not make
> much sense, so I guess this is just clutching for straws...
> 
>>> 0x800007D0 == PDH_CSTATUS_NO_MACHINE. The code (at line 68 mentioned
> 
> This is a weird error.
> 
>    "The path did not contain a computer name and the function was unable
>     to retrieve the local computer name."
> 
> Yeah, sure.
> 
> Mark, did you try to add the computer name to the path by calling
> GetComputerName() in load_init?

I tried more ham-handedly by prepending L"\\\\hostname" or L"\\\\.".  No change.
I'm running W10 21H2 on my home machines.  One with the issue is up-to-date with 
Windows patches.  Another that still shows reasonable load averages may not have 
the very latest patches; I need to verify that.

Some web page I found while searching for PDH stuff claimed that the performance 
counters are maintained by a Windows Service, which only gets started when some 
process attaches to pdh.dll.  I have to find that page again and see if it talks 
about which Windows versions that applies to.  That might possibly explain why one 
can't get reasonable counter numbers immediately after PdhOpenQuery.  But then, my 
running xload, which does load pdh.dll, should be seeing good counters.

..mark

  parent reply	other threads:[~2022-05-10  8:34 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 ` 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 [this message]
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                     ` load average calculation failing -- fixed by Windows update Jon Turney
2022-05-17 19:48                       ` 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=53664601-5858-ffd5-f854-a5c10fc25613@maxrnd.com \
    --to=mark@maxrnd.com \
    --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).