mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00

Reduce the overhead of `uv run` in large workspaces. Instead of re-discovering the entire workspace each time we resolve the metadata of a member, we can the discovered set of workspace members. Care needs to be taken to not cache the discovery for `uv init`, `uv add` and `uv remove`, which change the definitions of workspace members. Below is apache airflow e3fe06382df4b19f2c0de40ce7c0bdc726754c74 `uv run python` with a minimal payload. With this change, we avoid a ~350ms overhead of each `uv run` invocation. ``` $ hyperfine --warmup 2 \ "uv run --no-dev python -c \"print('hi')\"" \ "uv-profiling run --no-dev python -c \"print('hi')\"" Benchmark 1: uv run --no-dev python -c "print('hi')" Time (mean ± σ): 492.6 ms ± 7.0 ms [User: 393.2 ms, System: 97.1 ms] Range (min … max): 482.3 ms … 501.5 ms 10 runs Benchmark 2: uv-profiling run --no-dev python -c "print('hi')" Time (mean ± σ): 129.7 ms ± 2.5 ms [User: 105.4 ms, System: 23.2 ms] Range (min … max): 126.0 ms … 136.1 ms 22 runs Summary uv-profiling run --no-dev python -c "print('hi')" ran 3.80 ± 0.09 times faster than uv run --no-dev python -c "print('hi')" ``` The profile after those change below. We still spend a large chunk in toml parsing (both `uv.lock` and `pyproject.toml`), but it's not excessive anymore. 
63 lines
1.6 KiB
TOML
63 lines
1.6 KiB
TOML
[package]
|
|
name = "uv-bench"
|
|
version = "0.0.0"
|
|
description = "uv Micro-benchmarks"
|
|
publish = false
|
|
authors = { workspace = true }
|
|
edition = { workspace = true }
|
|
rust-version = { workspace = true }
|
|
homepage = { workspace = true }
|
|
documentation = { workspace = true }
|
|
repository = { workspace = true }
|
|
license = { workspace = true }
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[lib]
|
|
doctest = false
|
|
bench = false
|
|
|
|
[[bench]]
|
|
name = "distribution-filename"
|
|
path = "benches/distribution_filename.rs"
|
|
harness = false
|
|
|
|
[[bench]]
|
|
name = "uv"
|
|
path = "benches/uv.rs"
|
|
harness = false
|
|
|
|
[dependencies]
|
|
uv-cache = { workspace = true }
|
|
uv-client = { workspace = true }
|
|
uv-configuration = { workspace = true }
|
|
uv-dispatch = { workspace = true }
|
|
uv-distribution = { workspace = true }
|
|
uv-distribution-filename = { workspace = true }
|
|
uv-distribution-types = { workspace = true }
|
|
uv-extract = { workspace = true, optional = true }
|
|
uv-install-wheel = { workspace = true }
|
|
uv-pep440 = { workspace = true }
|
|
uv-pep508 = { workspace = true }
|
|
uv-platform-tags = { workspace = true }
|
|
uv-pypi-types = { workspace = true }
|
|
uv-python = { workspace = true }
|
|
uv-resolver = { workspace = true }
|
|
uv-types = { workspace = true }
|
|
uv-workspace = { workspace = true }
|
|
|
|
anyhow = { workspace = true }
|
|
codspeed-criterion-compat = { version = "2.7.2", default-features = false, optional = true }
|
|
criterion = { version = "0.5.1", default-features = false, features = ["async_tokio"] }
|
|
jiff = { workspace = true }
|
|
tokio = { workspace = true }
|
|
|
|
[package.metadata.cargo-shear]
|
|
ignored = ["uv-extract"]
|
|
|
|
[features]
|
|
codspeed = ["codspeed-criterion-compat"]
|
|
performance = [
|
|
"uv-extract/performance"
|
|
]
|