Giter Site home page Giter Site logo

PdhValidatePath unexpected errors about win HOT 6 OPEN

lxn avatar lxn commented on July 18, 2024
PdhValidatePath unexpected errors

from win.

Comments (6)

jwenz723 avatar jwenz723 commented on July 18, 2024 1

I think I may have found a solution to this problem. My previous method was using 1 PDH Query Handle per PDH Counter. I changed my code so that now only 1 PDH Query Handle is used to contain ALL PDH Counters. This seems to cause all of the errors that were occurring to stop. It appears that PDH has an undocumented limit on how many PDH Queries can be opened simultaneously.

I updated my small test project here to reflect these changes.

So I believe that this repository can remain unchanged and that the errors I was experiencing were just due to my limited understanding of how to properly use PDH.

from win.

krpors avatar krpors commented on July 18, 2024

I'm the original committer of pdh.go but has been quite some time since I last used it myself... Anyway, one thing I can say that everything is obviously just a wrapper around the DLL. Pretty good chance that it's just how the whole thing 'works' :)

Are you able to write up the smallest test case which is able to reproduce it? I could check it tonight, (also when there's no corporate proxy interfering).

from win.

jwenz723 avatar jwenz723 commented on July 18, 2024

Well I wrote up a small test case and put it in this repo.

What I am finding now, is that the PdhCollectQueryData function is actually the problem rather than the PdhValidatePath. Like I said before, the issue is very inconsistent.

To run the test program, fill the counters.txt file with a large amount of pdh counter paths (1 per line). I just ran in a command prompt: typeperf -q then copied the output into counters.txt.

It seems to me that the problem might start occurring when too many PDH queries are opened at the same time? But i'm not sure what 'too many' is. Or how to catch that. Any insight would be very helpful.

from win.

krpors avatar krpors commented on July 18, 2024

OK I tried something. I used typeperf -q > counters.txt and ran your test program and observed that the PdhCollectQueryData indeed looks to be the culprit here. I got a total of 1877 counters. 456 went into error due to the PdhCollectQueryData and 13 due to PdhAddEnglishCounter.

I took one of the groups which failed (\Distributed Routing Table(*)) and tried adding them all using the Windows Performance Monitor instead (perfmon.exe). They did not show up in the graph, and no error was displayed. Couldn't see anything in the event viewer as well. I'm unsure what is going on here.

I found this link but that did not seem to work on my machine (Windows 7 Enterprise).

Edit: I also tried putting a sleep of 10, 50 and 100 ms in the loop, but that did not have any effect. I got deterministic output, so it seems.

from win.

jwenz723 avatar jwenz723 commented on July 18, 2024

That article you found is interesting. I tried running the lodctr /r command, but it also seemed to have no effect. It doesn't seem to me like the errors are occurring because of corruption. Rather it seems like the number of counters being gathered simultaneously has exceeded what pdh is capable of handling.

Wish there was more documentation on the win pdh stuff.

from win.

krpors avatar krpors commented on July 18, 2024

Awesome!

Perhaps it's a good idea to document this behavior or whatever into the documentation of pdh.go. I agree that PDH is rather cryptic. I therefore tried to document its usage as properly as possible back in the day. I suppose your finding is a rather useful addition.

from win.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.