mirror of
https://github.com/astral-sh/ruff
synced 2026-01-20 21:10:48 -05:00
perf: Use custom allocator (#2768)
This PR replaces the system allocator with a custom allocator to improve performance: * Windows: mimalloc * Unix: tikv-jemallocator ## Performance: * Linux * `cpython --no-cache`: 208.8ms -> 190.5ms * `cpython`: 32.8ms -> 31ms * Mac: * `cpython --no-cache`: 436.3ms -> 380ms * `cpython`: 40.9ms -> 39.6ms * Windows: * `cpython --no-cache`: 367ms -> 268ms * `cpython`: 92.5ms -> 92.3ms ## Size * Linux: +5MB from 13MB -> 18MB (I need to double check this) * Mac: +0.7MB from 8.3MB-> 9MB * Windows: -0.16MB from 8.29MB -> 8.13MB (that's unexpected)
This commit is contained in:
@@ -61,3 +61,9 @@ ureq = { version = "2.5.0", features = [] }
|
||||
|
||||
[package.metadata.maturin]
|
||||
name = "ruff"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
mimalloc = "0.1.29"
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
tikv-jemallocator = "0.5.0"
|
||||
|
||||
@@ -24,6 +24,14 @@ mod iterators;
|
||||
mod printer;
|
||||
mod resolve;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[global_allocator]
|
||||
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||
|
||||
enum ExitStatus {
|
||||
/// Linting was successful and there were no linting errors.
|
||||
Success,
|
||||
|
||||
Reference in New Issue
Block a user