Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Increase the size of rayon threadpool for syscalls #189

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ reflink-copy = { version = "0.1.9" }
junction = { version = "1.0.0" }
reqwest = { version = "0.11", default-features = false, features = ["json", "native-tls-vendored"] }
node-semver = { version = "2.1.0" }
num_cpus = { version = "1.16.0" }
pipe-trait = { version = "0.4.0" }
rayon = { version = "1.8.0" }
serde = { version = "1.0.188", features = ["derive"] }
Expand All @@ -54,6 +55,7 @@ sha2 = { version = "0.10.8" }
split-first-char = { version = "0.0.0" }
ssri = { version = "9.0.0" }
strum = { version = "0.25.0", features = ["derive"] }
swc_malloc = { version = "0.5.9" }
tar = { version = "0.4.40" }
text-block-macros = { version = "0.1.1" }
tracing = { version = "0.1.37" }
Expand All @@ -78,9 +80,9 @@ allow_branch = "main"
opt-level = 3
lto = "fat"
codegen-units = 1
strip = "symbols"
debug = false
panic = "abort" # Let it crash and force ourselves to write safe Rust.
# strip = "symbols"
# debug = false
panic = "abort" # Let it crash and force ourselves to write safe Rust.

# Use the `--profile release-debug` flag to show symbols in release mode.
# e.g. `cargo build --profile release-debug`
Expand Down
3 changes: 3 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ miette = { workspace = true }
reqwest = { workspace = true }
pipe-trait = { workspace = true }
tokio = { workspace = true }
swc_malloc = { workspace = true }
rayon = { workspace = true }
num_cpus = { workspace = true }

[dev-dependencies]
pacquet-store-dir = { workspace = true }
Expand Down
12 changes: 12 additions & 0 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
extern crate swc_malloc;

mod cli_args;
mod state;

Expand All @@ -8,6 +10,16 @@ use pacquet_diagnostics::enable_tracing_by_env;
use state::State;

pub async fn main() -> miette::Result<()> {
// We use rayon only for blocking syscalls, so we multiply the number of threads by 3.
//
// If we are going to use rayon for CPU-bound tasks,
// we should create an extra threadpool for IO-bound tasks,
// and use the global theadpool for CPU-bound tasks.
rayon::ThreadPoolBuilder::new()
.num_threads(num_cpus::get() * 3)
.build_global()
.expect("build rayon thread pool");

enable_tracing_by_env();
set_panic_hook();
CliArgs::parse().run().await
Expand Down
Loading