Skip to content
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
71 changes: 64 additions & 7 deletions .github/workflows/pm-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,81 @@ name: utoopm-benchmark

on:
workflow_dispatch:
inputs:
registry:
description: 'Registry to test'
required: true
default: 'both'
type: choice
options:
- both
- npmjs
- npmmirror
pull_request:
types: [labeled]

jobs:
build:
runs-on: macos-latest

benchmark:
# 手动触发 或 PR 添加 benchmark label 时运行
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.label.name == 'benchmark')
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Init git submodules
run: git submodule update --init --recursive --depth 1

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2025-10-27
components: rustfmt, clippy

- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
shared-key: pm-bench
shared-key: pm-bench-${{ matrix.os }}

- name: Build utoo-pm
run: cargo build --release --bin utoo -p utoo-pm

- name: Update PATH
run: echo "${{ github.workspace }}/target/release" >> $GITHUB_PATH

- name: Create ut symlink
run: ln -sf utoo $(dirname $(which utoo))/ut

- name: Install yarn
run: npm install -g yarn

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: latest

- name: Install bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Verify package managers
run: |
echo "utoo: $(utoo --version)"
echo "yarn: $(yarn --version)"
echo "pnpm: $(pnpm --version)"
echo "bun: $(bun --version)"

- name: Run Benchmark
run: cargo bench -p utoo-pm
- name: Run benchmark
run: |
chmod +x e2e/pm-bench.sh
bash e2e/pm-bench.sh ${{ github.event.inputs.registry || 'both' }}
78 changes: 30 additions & 48 deletions Cargo.lock

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

17 changes: 10 additions & 7 deletions crates/pm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ path = "src/main.rs"

[dependencies]
anyhow = { workspace = true }
async-compression = { version = "0.3", features = ["gzip", "tokio"] }
# async-compression removed - using libdeflate for faster gzip decompression
atty = "0.2"
bytes = "1.11.0"
chrono = { version = "0.4", features = ["serde"] }
clap = { workspace = true }
colored = "2.1"
Expand All @@ -25,9 +26,11 @@ futures = { workspace = true }
glob = "0.3.1"
indicatif = "0.17.8"
libc = "0.2"
libdeflater = "1.25"
once_cell = "1.19"
owo-colors = { workspace = true }
petgraph = "0.6"
rayon.workspace = true
regex = "1.10"
reqwest = { version = "0.12", default-features = false, features = [
"gzip",
Expand All @@ -44,13 +47,13 @@ tempfile = "3.15.0"
term_size = "0.3"
tokio-fs-ext = { workspace = true }
tokio-retry = "0.3"
tokio-tar = "0.3.1"
tokio-util = { version = "0.7", features = ["io"] }
toml = { workspace = true }
tracing = { workspace = true }
tracing-appender = "0.2"
# tokio-tar removed - using sync tar with spawn_blocking for libdeflate batch processing
tokio-util = { version = "0.7" }
Comment on lines +50 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment for tokio-tar removal is clear, but the removal of features = ["io"] from tokio-util is not explicitly mentioned. While it might be implicitly handled by the new approach, it would be good to add a brief note about why these specific features are no longer needed or if they are now covered by other dependencies.

toml = { workspace = true }
tracing = { workspace = true }
tracing-appender = "0.2"
tracing-subscriber = { workspace = true }
utoo-ruborist = { path = "../ruborist" }
utoo-ruborist = { path = "../ruborist" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { workspace = true, features = ["full"] }
Expand Down
17 changes: 17 additions & 0 deletions crates/pm/src/helper/fs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Tokio-based glob implementation for ruborist's Glob trait.

use std::path::{Path, PathBuf};
use utoo_ruborist::progress::EventReceiver;
use utoo_ruborist::service::{BuildDepsOptions, Glob, UnifiedRegistry};

use crate::util::cache::get_cache_dir;
Expand Down Expand Up @@ -47,6 +48,22 @@ impl Context {
}
}

/// Create BuildDepsOptions with a custom event receiver.
pub async fn build_deps_options_with_receiver<R: EventReceiver>(
cwd: PathBuf,
receiver: R,
) -> BuildDepsOptions<GlobImpl, R> {
BuildDepsOptions {
cwd,
registry_url: get_registry(),
cache_dir: Some(get_cache_dir()),
concurrency: get_manifests_concurrency_limit().await,
legacy_peer_deps: get_legacy_peer_deps().await,
glob: TokioGlob,
receiver,
}
}

/// Create a UnifiedRegistry with standard configuration.
pub fn registry() -> Registry {
UnifiedRegistry::builder()
Expand Down
Loading
Loading