Skip to content

Commit 6a8104b

Browse files
authored
Remove sequential madvise for compressed blocks in StaticSortedFile (#91263)
## Summary Remove the per-block `madvise(MADV_SEQUENTIAL)` call before decompression in `StaticSortedFile`. The primary motivation is that the kernel splits mmap regions internally when they receive different `madvise` hints. Each per-block `MADV_SEQUENTIAL` call fragments the VMA (Virtual Memory Area) for the file mapping. For larger builds with many compressed blocks, this causes the process to hit the `vm.max_map_count` limit, leading to failures. Additionally, the file-level `MADV_RANDOM` advice is sufficient on its own — the sequential hint for individual compressed blocks adds syscall overhead without meaningful benefit, since the decompressor already performs a linear scan in userspace and the blocks are already mapped in memory. ## Changes - Removed the `madvise(Sequential)` call in `StaticSortedFile::get_block()` for compressed blocks (`turbopack/crates/turbo-persistence/src/static_sorted_file.rs`) ## Test Plan - Existing turbo-persistence tests continue to pass - This is a performance-only change with no functional impact
1 parent 1411870 commit 6a8104b

1 file changed

Lines changed: 0 additions & 11 deletions

File tree

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -541,17 +541,6 @@ impl StaticSortedFile {
541541
return Ok(self.mmap_slice_to_arc_bytes(block));
542542
}
543543

544-
// Advise Sequential only here: we're about to linearly scan the block
545-
// through the decompressor. For uncompressed blocks (returned above)
546-
// and lazy medium values (which call get_raw_block directly without
547-
// decompressing), the file-level Random advice applies.
548-
#[cfg(unix)]
549-
let _ = self.mmap.advise_range(
550-
memmap2::Advice::Sequential,
551-
block.as_ptr() as usize - self.mmap.as_ptr() as usize,
552-
block.len(),
553-
);
554-
555544
let buffer = decompress_into_arc(uncompressed_length, block).with_context(|| {
556545
format!(
557546
"Failed to decompress block {} from {:08}.sst ({} bytes uncompressed)",

0 commit comments

Comments
 (0)