Skip to content

Commit 3970f45

Browse files
ndmitchellfacebook-github-bot
authored andcommitted
Use jemalloc open source
Summary: Internally, we default to jemalloc, so all our optimisations and profiling is done with jemalloc. Use the same on linux/mac. Improves performance on `time pyrefly check torch -o /dev/null` from 3.6s to 1.6s. Reviewed By: SamChou19815 Differential Revision: D73927808 fbshipit-source-id: ec41ff5fca3bb9d0d1c3f6cfac9a1daaeb96d019
1 parent 0718b0d commit 3970f45

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pyrefly/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ tar = "0.4.44"
7474
zstd = { version = "0.13", features = ["experimental", "zstdmt"] }
7575

7676
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
77+
jemallocator = "0.5.4"
7778
watchman_client = "0.9.0"
7879
which = "4.2.4"
7980
zstd = { version = "0.13", features = ["experimental", "zstdmt"] }

pyrefly/bin/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ use pyrefly::library::library::library::library;
3636
use tracing::debug;
3737
use tracing::info;
3838

39+
// fbcode likes to set its own allocator in fbcode.default_allocator
40+
// So when we set our own allocator, buck build buck2 or buck2 build buck2 often breaks.
41+
// Making jemalloc the default only when we do a cargo build.
42+
#[global_allocator]
43+
#[cfg(all(any(target_os = "linux", target_os = "macos"), not(fbcode_build)))]
44+
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
45+
3946
#[derive(Debug, Parser)]
4047
#[command(name = "pyrefly")]
4148
#[command(about = "Next generation of Pyre type checker", long_about = None)]

0 commit comments

Comments
 (0)