poop
poop copied to clipboard
Add support for non-Linux platforms (but with fewer measurements)
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:
(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.~~
Potential additions (belongs into new issue, if not implemented here):
-
- Darwin perf counters https://lemire.me/blog/2021/03/24/counting-cycles-and-instructions-on-the-apple-m1-processor/
-
- Windows perfcounters https://learn.microsoft.com/en-us/windows/win32/wmisdk/accessing-performance-data-in-c-- and https://learn.microsoft.com/en-us/windows/win32/api/_perf/, however I have no idea about the ntdll apis and their stabililty.
I'd love to see this merged once conflicts are resolved. Sorry to bother you, but any thoughts, @andrewrk?
I think windows has hardware counters, doesn't it? If so then I think a windows version should use them.
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.
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.
https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-performance_data seems relevant
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.
Any updates @squeek502 ?
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.