Skip to content

Commit 37aed86

Browse files
sokraclaude
authored andcommitted
turbo-persistence: remove Unmergeable mmap advice (#91713)
Remove the `MADV_UNMERGEABLE` (Unmergeable) mmap advice from `turbo-persistence`'s `advise_mmap_for_persistence` helper in `mmap_helper.rs`. The WSL (Windows Subsystem for Linux) kernel does not support `MADV_UNMERGEABLE` and returns an error when it is applied, causing turbo-persistence to fail on WSL. See: https://x.com/von_cronen/status/2034944304712392891 Additionally, `MADV_UNMERGEABLE` is already the **default** state for memory pages — KSM (Kernel Same-page Merging) is opt-in via `MADV_MERGEABLE`. Explicitly setting `MADV_UNMERGEABLE` on pages that were never marked mergeable is a no-op on standard kernels, so the call provides no benefit while breaking WSL users. The `MADV_DONTFORK` advice is retained, as it has a clear correctness benefit (prevents mmap regions from being inherited by child processes on `fork()`). Removed the `mmap.advise(memmap2::Advice::Unmergeable)` call and its associated doc comment from `turbopack/crates/turbo-persistence/src/mmap_helper.rs`. Co-authored-by: Tobias Koppers <sokra@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent d6195ec commit 37aed86

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

turbopack/crates/turbo-persistence/src/mmap_helper.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
///
33
/// - `DontFork`: prevents mmap regions from being copied into child processes on `fork()`, avoiding
44
/// unnecessary memory duplication and potential SIGBUS.
5-
/// - `Unmergeable`: opts pages out of KSM (Kernel Same-page Merging) since our data is unique
6-
/// compressed content that won't benefit from deduplication scanning.
75
#[cfg(target_os = "linux")]
86
pub fn advise_mmap_for_persistence(mmap: &memmap2::Mmap) -> anyhow::Result<()> {
9-
mmap.advise(memmap2::Advice::DontFork)?;
10-
mmap.advise(memmap2::Advice::Unmergeable)?;
7+
use anyhow::Context;
8+
mmap.advise(memmap2::Advice::DontFork)
9+
.context("Failed to advise mmap DontFork")?;
1110
Ok(())
1211
}
1312

0 commit comments

Comments
 (0)