-
-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix user and kernel times on Windows #538
Conversation
97116dc
to
8354ef6
Compare
Thank you very much for your contribution and for the clear implementation & documentation!
Just to make sure: the linked ticket says "Finding that thread from the process handle can be a bit convoluted", which sounds like it is actually possible to retrieve the handle without that nightly-only feature (potentially using some low-level
Thank you. I think I understand the intention behind the feature gate. On the other hand, it's not like the current In this sense, I think it would be great if the absence of the new feature gate would completely disable the user/kernel time feature on Windows. What do you think? Minor point: calling this feature |
@sharkdp thanks for your comments. I'll look into them tomorrow. I already found a undocumented ntdll function NtResumeProcess, which resumes a process by HANDLE, which we could potentially use and before that I played around with a implementation using CreateToolhelp32Snapshot for finding the main thread, but using NtResumeProcess should definitely be better in terms of performance and code size 😁. |
8354ef6
to
8d859f7
Compare
8d859f7
to
3242e0a
Compare
With the latest commit it works on stable using the undocumented but well known |
@sharkdp ping. Can I do something to help merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - this is great! Thank you very much.
Description
By using a job object and attaching it to the spawned process before launch, we can record the total user and kernel times of it and all of its child processes. Sadly extracting the raw handle of the
main_thread_handle
is still nightly only 😢 (see: rust-lang/rust#96723) and required, in order to resume a initially suspended process. Therefore this new CPUTimer implementation is guarded behind a newnightly
cargo feature and not enabled by default.Example
Before:
After:
Fixes: #368