-
Notifications
You must be signed in to change notification settings - Fork 26
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
First draft of macOS + BSD plugins #81
base: master
Are you sure you want to change the base?
Conversation
It makes it very easy to have 2 implementation of plugins. Only the correct one gets compiled and linked to the global executable.
awesome 👌 i need to fix the tests suite it seems 😅 |
And, thanks for keeping my |
printf("speculative.value %lu\n", stats.speculative_count * pagesize); | ||
|
||
int64_t freePages = stats.free_count - stats.speculative_count; | ||
printf("other.value %lu\n", MAX(0, (int64_t)totalPages - stats.wire_count - stats.active_count - stats.inactive_count - freePages) * pagesize); |
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.
Do not hesitate to use temporary named variables.
They get optimized away and help understanding and debugging: 😉
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.
Oh, yes, definitely. I think the problem here is that I don't understand how these numbers are supposed to add up, and I haven't been able to find complete documentation on them. I found https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/osfmk/mach/vm_statistics.h#L108-L111 which says:
speculative pages are already accounted for in "free_count", so "speculative_count" is the number of "free" pages that are used to hold data that was read speculatively from disk but haven't actually been used by anyone so far.
…so I've defined freePages = stats.free_count - stats.speculative_count
.
But often the values in vm_statistics
don't sum to exactly vm.pages
— sometimes the sum is less than vm.pages
(represented by the other.value
I added); sometimes the sum is more than vm.pages
(thus the need for MAX(0, …)
to keep it from wrapping).
Here's what the latest revision (7b2914a) looks like for an 8 GB system:
@steveschnepp, I've made some progress on your work in PR #47:
master
branch