diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/build.rs | 10 | ||||
-rw-r--r-- | cli/tsc/mod.rs | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/cli/build.rs b/cli/build.rs index 752b80635..d71b92e1a 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -280,7 +280,17 @@ mod ts { startup_snapshot: None, extensions: vec![], extensions_with_js: vec![tsc_extension], + + // NOTE(bartlomieju): Compressing the TSC snapshot in debug build took + // ~45s on M1 MacBook Pro; without compression it took ~1s. + // Thus we're not not using compressed snapshot, trading off + // a lot of build time for some startup time in debug build. + #[cfg(debug_assertions)] + compression_cb: None, + + #[cfg(not(debug_assertions))] compression_cb: Some(Box::new(|vec, snapshot_slice| { + eprintln!("Compressing TSC snapshot..."); vec.extend_from_slice( &zstd::bulk::compress(snapshot_slice, 22) .expect("snapshot compression failed"), diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs index c9ff4668a..343df71df 100644 --- a/cli/tsc/mod.rs +++ b/cli/tsc/mod.rs @@ -56,6 +56,14 @@ pub static COMPILER_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new( static COMPRESSED_COMPILER_SNAPSHOT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.bin")); + // NOTE(bartlomieju): Compressing the TSC snapshot in debug build took + // ~45s on M1 MacBook Pro; without compression it took ~1s. + // Thus we're not not using compressed snapshot, trading off + // a lot of build time for some startup time in debug build. + #[cfg(debug_assertions)] + return COMPRESSED_COMPILER_SNAPSHOT.to_vec().into_boxed_slice(); + + #[cfg(not(debug_assertions))] zstd::bulk::decompress( &COMPRESSED_COMPILER_SNAPSHOT[4..], u32::from_le_bytes(COMPRESSED_COMPILER_SNAPSHOT[0..4].try_into().unwrap()) |