Skip to content

Commit

Permalink
[Turbopack] fix mmap advise on windows (#73462)
Browse files Browse the repository at this point in the history
### What?

The import is only available on unix and windows will fail to compile
  • Loading branch information
sokra authored Dec 3, 2024
1 parent c9aae2f commit f95da29
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions turbopack/crates/turbo-persistence/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{
use anyhow::{bail, Context, Result};
use byteorder::{ReadBytesExt, WriteBytesExt, BE};
use lzzzz::lz4::decompress;
use memmap2::{Advice, Mmap};
use memmap2::Mmap;
use parking_lot::{Mutex, RwLock};
use rayon::iter::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator};

Expand Down Expand Up @@ -331,13 +331,13 @@ impl TurboPersistence {
let path = self.path.join(format!("{:08}.blob", seq));
let mmap = unsafe { Mmap::map(&File::open(&path)?)? };
#[cfg(unix)]
mmap.advise(Advice::Sequential)?;
mmap.advise(memmap2::Advice::Sequential)?;
#[cfg(unix)]
mmap.advise(Advice::WillNeed)?;
mmap.advise(memmap2::Advice::WillNeed)?;
#[cfg(target_os = "linux")]
mmap.advise(Advice::DontFork)?;
mmap.advise(memmap2::Advice::DontFork)?;
#[cfg(target_os = "linux")]
mmap.advise(Advice::Unmergeable)?;
mmap.advise(memmap2::Advice::Unmergeable)?;
let mut compressed = &mmap[..];
let uncompressed_length = compressed.read_u32::<BE>()? as usize;

Expand Down

0 comments on commit f95da29

Please sign in to comment.