Skip to content
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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

smokris
Copy link
Contributor

@smokris smokris commented Sep 7, 2022

@steveschnepp, I've made some progress on your work in PR #47:

  • rebased on latest master branch
  • all plugins now build and run on both macOS 12.5.1 and FreeBSD 13.1 (though a few plugins remain unimplemented since I haven't found corresponding APIs)

@steveschnepp
Copy link
Member

awesome 👌

i need to fix the tests suite it seems 😅

@steveschnepp
Copy link
Member

And, thanks for keeping my plugin-API.c idea

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);
Copy link
Member

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: 😉

Copy link
Contributor Author

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:

memory-day

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

Successfully merging this pull request may close these issues.

2 participants