mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:37 +00: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:
parent
d0f9ee33ec
commit
863e39fe5f
3 changed files with 55 additions and 0 deletions
41
Cargo.lock
generated
41
Cargo.lock
generated
|
@ -1186,6 +1186,16 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libmimalloc-sys"
|
||||||
|
version = "0.1.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd8c7cbf8b89019683667e347572e6d55a7df7ea36b0c4ce69961b0cde67b174"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "link-cplusplus"
|
name = "link-cplusplus"
|
||||||
version = "1.0.8"
|
version = "1.0.8"
|
||||||
|
@ -1256,6 +1266,15 @@ dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mimalloc"
|
||||||
|
version = "0.1.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9dcb174b18635f7561a0c6c9fc2ce57218ac7523cf72c50af80e2d79ab8f3ba1"
|
||||||
|
dependencies = [
|
||||||
|
"libmimalloc-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.6.2"
|
version = "0.6.2"
|
||||||
|
@ -1970,6 +1989,7 @@ dependencies = [
|
||||||
"ignore",
|
"ignore",
|
||||||
"itertools",
|
"itertools",
|
||||||
"log",
|
"log",
|
||||||
|
"mimalloc",
|
||||||
"notify",
|
"notify",
|
||||||
"path-absolutize",
|
"path-absolutize",
|
||||||
"quick-junit",
|
"quick-junit",
|
||||||
|
@ -1982,6 +2002,7 @@ dependencies = [
|
||||||
"similar",
|
"similar",
|
||||||
"strum",
|
"strum",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
|
"tikv-jemallocator",
|
||||||
"ureq",
|
"ureq",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
@ -2508,6 +2529,26 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tikv-jemalloc-sys"
|
||||||
|
version = "0.5.3+5.3.0-patched"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tikv-jemallocator"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "20612db8a13a6c06d57ec83953694185a367e16945f66565e8028d2c0bd76979"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"tikv-jemalloc-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.45"
|
version = "0.1.45"
|
||||||
|
|
|
@ -61,3 +61,9 @@ ureq = { version = "2.5.0", features = [] }
|
||||||
|
|
||||||
[package.metadata.maturin]
|
[package.metadata.maturin]
|
||||||
name = "ruff"
|
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 printer;
|
||||||
mod resolve;
|
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 {
|
enum ExitStatus {
|
||||||
/// Linting was successful and there were no linting errors.
|
/// Linting was successful and there were no linting errors.
|
||||||
Success,
|
Success,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue