summaryrefslogtreecommitdiff
path: root/cli/tsc/mod.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-02-14 02:46:32 +0100
committerGitHub <noreply@github.com>2023-02-14 02:46:32 +0100
commit2502a37d41e8a7f279af74d7dacc009ee1010f67 (patch)
tree74b4242404ea3041126af1cebb906863615a1eaa /cli/tsc/mod.rs
parent0f1349bca8d40dff23098e141363c956a8dd7875 (diff)
chore(build): don't compress TSC snapshot in debug build (#17772)
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.
Diffstat (limited to 'cli/tsc/mod.rs')
-rw-r--r--cli/tsc/mod.rs8
1 files changed, 8 insertions, 0 deletions
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())