andrewrk / poop

Performance Optimizer Observation Platform
MIT License
788 stars 50 forks source link

Add support for non-Linux platforms (but with fewer measurements) #37

Open squeek502 opened 1 year ago

squeek502 commented 1 year ago

This is something of a proof-of-concept. The idea is to include the perf measurements when they are available, but when they're not, only wall time and maxrss are measured and shown. The method of achieving this used in this PR could probably use some work, this is just what I came up with first.

Screenshot from Windows:

poop-on-windows

(benefits from https://github.com/ziglang/zig/pull/16294 to fix the colors)

Note: I've only tested it on Windows, so I may have broken Linux inadvertently. EDIT: Yep, I broke Linux--will fix that.

matu3ba commented 1 year ago

Potential additions (belongs into new issue, if not implemented here):

p7r0x7 commented 9 months ago

I'd love to see this merged once conflicts are resolved. Sorry to bother you, but any thoughts, @andrewrk?

andrewrk commented 9 months ago

I think windows has hardware counters, doesn't it? If so then I think a windows version should use them.

squeek502 commented 9 months ago

If anyone can point me to a concrete example of how the relevant information can be obtained on Windows (like "here's C++ code that prints out the number of cache misses in a program"), I'd take a look. I can't make heads or tails of any of the documentation/information around it.

My best guess right now is that the answer is effectively, "windows does not have [relevant/useful] hardware counters." With possibly a caveat around Intel processors, specifically.

matu3ba commented 9 months ago

My best guess right now is that the answer is effectively, "windows does not have [relevant/useful] hardware counters." With possibly a caveat around Intel processors, specifically.

ETW are using them. Would be this blog post sufficient? https://adamsitnik.com/Hardware-Counters-ETW/ based on https://github.com/microsoft/perfview/blob/main/documentation/TraceEvent/TraceEventLibrary.md.

Otherwise, I would use this tool, which includes an sophisticated analyzer https://tinyurl.com/etwtracing.

Probably the most simple way is to use WPR and WPA as explained in https://learn.microsoft.com/en-us/windows-hardware/test/wpt/event-tracing-for-windows.

UPDATE: found the lib https://learn.microsoft.com/en-us/windows/win32/api/perflib/ and some more info https://learn.microsoft.com/en-us/windows/win32/perfctrs/using-the-perflib-functions-to-consume-counter-data.

notcancername commented 9 months ago

https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-performance_data seems relevant

p7r0x7 commented 8 months ago

Building for MacOS proved successful, but running it only yielded a memory leak and and a couple new lines were printed to the terminal before I had to ^C it.

p7r0x7 commented 7 months ago

Any updates @squeek502 ?

squeek502 commented 7 months ago

Not currently planning on working on this much more. As mentioned in the OP, this is mostly meant as a proof-of-concept. If others want to take it further they are more than welcome to.

I've been hitting something like https://github.com/andrewrk/poop/issues/43 or other stdout/stderr/process spawning related issues often when trying to use poop (especially on Windows), so I've not been using it much personally.