-
Notifications
You must be signed in to change notification settings - Fork 888
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
Add an option to reduce pagefault when available #430
base: dev
Are you sure you want to change the base?
Conversation
If you would like to share the benchmark results, you shall describe the hardware configurations. "6 CPU cores" is too rough. Instead, mention the microarchitecture at least. |
Besides the reducing of page fault amounts, the elapsed time should be listed for each run. |
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.
The git commit message is not as informative as what "readme.md" was changed. You should improve the messages.
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.
Wrap the body of git commit messages at 72 characters as the article How to Write a Git Commit Message suggests.
You shall mention that it is specific to Linux only.
It would be great if the comprehensive experimental results of |
This option instructs the kernel to synchronously load the entire mapped region into active memory by specifying `MAP_POPULATE` in `mmap`. It will cause read-ahead on that memory, and then the subsequent accesses to the memory can proceed without page faults, improving some performance.
Hi @hankluo6 ; thanks for your PR. At this moment I am hesitant though, as jserv remarks we need to measure more. It sounds great of course to reduce page-faults by pre-populating and it seems indeed that the (smallish) benchmarks get faster. But generally with large (real-world) workloads we usually try to avoid touching any pages that may not be needed after all. For example, for each block size mimalloc reservers mimalloc "pages" that are usually about 64k but it only touches at first the initial OS page (of 4k) -- in case just few objects are needed, all the other OS pages (60k) keep being just virtual address space without needing real physical memory. That can be a big fraction due to memory fragmentation. So, generally, I would say it is not a good idea to do this. This is also why the Anyways, I need some more thinking on this and better understand the impact. Best, Daan |
This PR add
MAP_POPULATE
flag inmi_unix_mmap
and enable user to control it through the new option (MIMALLOC_PREFAULT
).The
MAP_POPULATE
will prefault the page tables and therefore can reduce some page fault in the runtime. This can improve some performance.In my system, Linux x86_64 with i5-8300H CPU and 1 numa node, test with
./mimalloc-test-stress 32 100 50
in debug build,Results:
MAP_POPULATE
causes around2,943,560
page faults and 205 secondsMAP_POPULATE
causes around94,554
page faults and 203 secondsI also test in mimalloc-bench. With
eager_commit = 0
, page-fault in most benchmark (cfrac, espresso, larsonN) are increase about 65000 and other big test (leanN, mstressN) will increase even more. And witheager_commit = 1
, settingMAP_POPULATE
can't see any significant effects and the page-fault is same like origin version.I think this is because the option
eager_commit
was set to 0 will prefaults some unused memory overall. Therefore, this option can get user an ability to tune by themselves.Btw, above page faults means main page faults and minor page faults.