Skip to content
Closed
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
5 changes: 3 additions & 2 deletions crates/pm/src/util/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ pub fn get_install_scope() -> InstallScope {
INSTALL_SCOPE.get().copied().unwrap_or_default()
}

// Manifest fetch concurrency configuration
// Manifest fetch concurrency configuration. Used by both preload (worker
// pool size) and downloader (Semaphore for tarball fetches).
static MANIFESTS_CONCURRENCY_LIMIT: LazyLock<ConfigValue<usize>> =
LazyLock::new(|| ConfigValue::new("manifests-concurrency-limit", 64));
LazyLock::new(|| ConfigValue::new("manifests-concurrency-limit", 128));

pub fn set_manifests_concurrency_limit(value: Option<usize>) {
MANIFESTS_CONCURRENCY_LIMIT.set(value);
Expand Down
30 changes: 15 additions & 15 deletions crates/ruborist/src/resolver/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::resolver::preload::{PreloadConfig, preload_manifests};
use crate::resolver::registry::{ResolveError, resolve_registry_dep};
use crate::spec::{Catalogs, PackageSpec, Protocol};
use crate::traits::progress::{BuildEvent, EventReceiver, NoopReceiver};
use crate::traits::registry::{RegistryClient, ResolvedPackage};
use crate::traits::registry::{PreloadRegistry, RegistryClient, ResolvedPackage};

/// Dispatch a git/github spec to the real `gix`-backed resolver when the
/// `native-git` feature is enabled, otherwise error with a hint.
Expand Down Expand Up @@ -707,7 +707,7 @@ pub async fn process_dependency<R: RegistryClient>(
/// // Add initial dependency edges to root...
/// build_deps(&mut graph, &registry, PeerDeps::Include).await?;
/// ```
pub async fn build_deps<R: RegistryClient>(
pub async fn build_deps<R: PreloadRegistry>(
graph: &mut DependencyGraph,
registry: &R,
peer_deps: PeerDeps,
Expand All @@ -729,7 +729,7 @@ pub async fn build_deps<R: RegistryClient>(
/// * `registry` - Registry client for fetching packages
/// * `peer_deps` - How to handle peer dependencies
/// * `receiver` - Event receiver for handling build events
pub async fn build_deps_with_receiver<R: RegistryClient, E: EventReceiver>(
pub async fn build_deps_with_receiver<R: PreloadRegistry, E: EventReceiver>(
graph: &mut DependencyGraph,
registry: &R,
peer_deps: PeerDeps,
Expand Down Expand Up @@ -759,7 +759,7 @@ pub async fn build_deps_with_receiver<R: RegistryClient, E: EventReceiver>(
///
/// build_deps_with_config(&mut graph, &registry, config, &receiver).await?;
/// ```
pub async fn build_deps_with_config<R: RegistryClient, E: EventReceiver>(
pub async fn build_deps_with_config<R: PreloadRegistry, E: EventReceiver>(
graph: &mut DependencyGraph,
registry: &R,
config: BuildDepsConfig,
Expand All @@ -786,7 +786,7 @@ pub async fn build_deps_with_config<R: RegistryClient, E: EventReceiver>(
}

/// Run the preload phase to warm up the cache with manifests.
async fn run_preload_phase<R: RegistryClient, E: EventReceiver>(
async fn run_preload_phase<R: PreloadRegistry, E: EventReceiver>(
graph: &DependencyGraph,
registry: &R,
config: &BuildDepsConfig,
Expand All @@ -804,18 +804,22 @@ async fn run_preload_phase<R: RegistryClient, E: EventReceiver>(
}

tracing::debug!("Preload phase: {} initial dependencies", initial_deps.len());
receiver.on_event(BuildEvent::PreloadStart {
count: initial_deps.len(),
});
// PreloadStart / PreloadComplete are emitted inside `preload_manifests`.

let preload_config = PreloadConfig {
peer_deps: config.peer_deps,
concurrency: config.concurrency,
};

// Wrap registry in Rc for the worker pool. Each worker holds a
// Rc<R> so resolution runs as an independent `spawn_local` task on
// the current thread. UnifiedRegistry's Clone is shallow (Arc-based),
// so this clone is cheap.
let registry_rc = std::rc::Rc::new(registry.clone());

let stats = preload_manifests(
initial_deps,
registry,
registry_rc,
preload_config,
receiver,
|_name, _manifest| {
Expand All @@ -829,10 +833,6 @@ async fn run_preload_phase<R: RegistryClient, E: EventReceiver>(
stats.success_count,
stats.failed_count
);
receiver.on_event(BuildEvent::PreloadComplete {
success: stats.success_count,
failed: stats.failed_count,
});

tracing::debug!("Preload phase: {:?}", start.elapsed());
}
Expand Down Expand Up @@ -961,7 +961,7 @@ use std::path::Path;
/// let pkg: PackageJson = serde_json::from_str(&pkg_content)?;
/// let lock = resolve(&pkg, &registry).await?;
/// ```
pub async fn resolve<R: RegistryClient>(
pub async fn resolve<R: PreloadRegistry>(
pkg: &PackageJson,
registry: &R,
) -> Result<PackageLock, ResolveError<R::Error>> {
Expand All @@ -975,7 +975,7 @@ pub async fn resolve<R: RegistryClient>(
/// * `registry` - Registry client for fetching packages
/// * `peer_deps` - How to handle peer dependencies
/// * `receiver` - Event receiver for progress tracking
pub async fn resolve_with_options<R: RegistryClient, E: EventReceiver>(
pub async fn resolve_with_options<R: PreloadRegistry, E: EventReceiver>(
pkg: &PackageJson,
registry: &R,
peer_deps: PeerDeps,
Expand Down
Loading
Loading