Skip to content

Add Frontend.NumInstructions statistic, populated on macOS by rusage_info_v4 #18658

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

Merged
merged 1 commit into from
Aug 13, 2018

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Aug 12, 2018

After all the fussing around I have done trying to get a reliable external tool to read off the PMC instruction counts for a subprocess tree on macOS (a la linux perf(1)) I was somewhat astonished to learn that XNU these days just always tracks every task's PMC-read instruction count (see: https://github.com/apple/darwin-xnu/blob/master/osfmk/kern/kern_monotonic.c and https://github.com/apple/darwin-xnu/blob/master/osfmk/x86_64/monotonic_x86_64.c) and returns it as a standard field in its rusage_info_v4 structure, if you ask via proc_pid_rusage.

So: this patch adds instruction counts to UnifiedStatsCollector / -stats-output-dir. I will be plumbing it through everything else subsequently -- it's a much less-noisy number to use than the time values, while being a decent proxy for it at the granularity we're concerned with -- but this gets the ball rolling.

@graydon graydon requested review from jrose-apple and xedin August 12, 2018 06:53
@graydon
Copy link
Contributor Author

graydon commented Aug 12, 2018

@swift-ci please test

@davidungar
Copy link
Contributor

Great find!

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I'm pretty surprised to learn that as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants