-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Remove mmap isLoaded check before madvise #14156
base: main
Are you sure you want to change the base?
Remove mmap isLoaded check before madvise #14156
Conversation
The counter guarding the `madvise` callback is not all that effective in preventing `madvise` calls on slices since it's not shared with the original input and this keeps showing up hot in profiling ES benchmarks. An outright `madvise` call should be about as expensive as the `isLoaded` check when things are already in the page cache and cheaper than that same call + a call to `isLoaded` that returns `false`, simply by avoiding another roundtrip to userspace. -> remove the isLoaded guard to speed up call cases
The overhead of Additionally, and orthogonally, I'm less sure of the checks anyway, since they don't count the against the actual memory range but rather against the whole segment. |
The PR where
Thinking out loud, this
These checks make an assumption that if many ranges of bytes on which |
Huh those results are quite unexpected I must admit :) When me and Chris reasoned about this, the idea was that |
Well, you may be right as well that the cost of What do you think of skipping the |
@jpountz I see. Hmm I wonder how much that saves us? Seems we just trade an EDIT: sorry scratch that question, both run against the same code, I misread things. So not sure how much that buys us on the fast path. It seems fundamentally, with it comes down to on my machine when benchmarking is that if everything's in the cache then either |
This is correct. I made this suggestion because it was similar to your initial proposal: skipping the
I'm good with exploring sharing state across slices as well. I optimized for simplicity with the current implementation, but we may be able to figure out something that works well across slices as well. |
The counter guarding the
madvise
callback is not all that effective in preventingmadvise
calls on slices since it's not shared with the original input and this keeps showing up hot in profiling ES benchmarks.An outright
madvise
call should be about as expensive as theisLoaded
check when things are already in the page cache and cheaper than that same call + a call toisLoaded
that returnsfalse
, simply by avoiding another roundtrip to userspace.-> remove the isLoaded guard to speed up call cases
Excerpt from ES profile motivating this:
Checking the page table for loaded is comparable in cost to many thousands of cycles in practice.
Plus, the racy nature of such a check reduces its value in memory constrained scenarios.