Repository navigation
Allow explicit populate of mmap - #4923
Conversation
|
depends on #4943 |
b80b82b to
78f6b57
Compare
| log::warn!( | ||
| "Failed to populate mmap{separator}{path:?} to cache: {err}", | ||
| separator = separator, | ||
| path = path, | ||
| err = err | ||
| ); |
There was a problem hiding this comment.
Style nit:
| log::warn!( | |
| "Failed to populate mmap{separator}{path:?} to cache: {err}", | |
| separator = separator, | |
| path = path, | |
| err = err | |
| ); | |
| log::warn!( | |
| "Failed to populate mmap{separator}{path:?} to cache: {err}" | |
| ); |
Also, It was already before this PR, but I don't think this separator logic works as expected. If path is None, it will print this: Failed to populate mmap"" to cache: …. Maybe it should be like this:
let path = path.map_or_else(|| "".to_string(), |path| format!(" {path:?}"));
…
log::warn!("Failed to populate mmap{path} to cache: {err}");|
|
||
| fn populate(&self) -> io::Result<()> { | ||
| #[cfg(target_os = "linux")] | ||
| self.advise(memmap2::Advice::PopulateRead)?; |
There was a problem hiding this comment.
This option requires Linux 5.14+. Some long-term supported distros (e.g. RHEL 8 and Ubuntu 20.04) still have older kernels. Maybe it would make sense to check beforehand if it is supported and fallback to the loop implementation if it isn't. Quote from madvise(2):
madvise(0, 0, advice) will return zero iff advice is supported by the kernel and can be relied on to probe for support.
There was a problem hiding this comment.
The check could be like this:
fn populate_read_is_supported() -> bool {
use std::sync::OnceLock;
static IS_SUPPORTED: OnceLock<bool> = OnceLock::new();
*IS_SUPPORTED.get_or_init(|| unsafe {
libc::madvise(std::ptr::null_mut(), 0, Advice::PopulateRead as libc::c_int) == 0
})
}There was a problem hiding this comment.
If we're running 5.14 (at least) in the cloud I don't think we should care too much about older versions.
We can, but I prefer to keep things simpler.
There was a problem hiding this comment.
In some cases we do use an older kernel version. So, lets follow your suggestion with the runtime check.
@xzfc I've tagged you in Slack where we've discussed this.
There was a problem hiding this comment.
Recap: we still have older versions somewhere.
And even if we didn't, performing this tiny check shouldn't complicate things much, since we already have the fallback code for non-Linux systems.
There was a problem hiding this comment.
I've implemented that in the last commit to this PR. It uses a new mmap2::Advise::is_supported() method added in https://www.github.com/RazrFalcon/memmap2-rs/pull/122.
72466d8 to
5c3912d
Compare
5c3912d to
d18b5e6
Compare
timvisee
left a comment
There was a problem hiding this comment.
LGTM assuming the open review comments get resolved
| # Temporary patch until memmap2 0.9.5 is released. | ||
| memmap2 = { git = "https://github.com/RazrFalcon/memmap2-rs" } |
* expose mmap populate * expose mmap populate in open_read_mmap * FOR TEST, REVERSE IT: make InRamChunkedMmap default * enable populate advise on unix * fix clippy * unix -> linux * Update lib/collection/src/config.rs * clippy fixes * resolve conflicts * fmt * Runtime check for PopulateRead --------- Co-authored-by: xzfc <[email protected]>

Uh oh!
There was an error while loading. Please reload this page.