From 307e66847dd5e00ad1890b6a64d3ac7192a03efc Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 18 Jul 2026 18:16:07 +0900 Subject: perf(installation-manager): fan out package downloads via Loop::wait MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InstallationManager::downloadAndExecuteBatch now matches PHP: every update/install operation's installer->download() promise is collected and driven concurrently through waitOnPromises()/Loop::wait instead of being awaited one package at a time. Concurrency caps stay where PHP puts them (HttpDownloader 12, ProcessExecutor 10 via their semaphores). Error semantics follow PHP too: all downloads settle before the first rejection is rethrown, rather than aborting on the first failure. To let the collected futures and the cleanup closures own their installer beyond the loop iteration that created them, the installer registry becomes Vec> and get_installer hands out clones (PHP closures capture $installer the same way), with InstallerInterface methods taking &self across the six implementors — the only genuinely mutable state was LibraryInstaller.vendor_dir (canonicalized in place), now behind a RefCell. as_plugin_installer_mut/as_binary_presence_interface lose their &mut. The cleanup_promises entries are now the real thing: the PHP closure including the getInstallationSource() guard and the installer->cleanup($opType, $package, $initialPackage) call, replacing the no-op futures (drops one TODO(phase-b) and two TODO(phase-c)). Verified against the real network: create-project laravel/laravel produces a vendor tree byte-identical to real Composer's (diff -rq clean across all 109 packages including vendor/composer). Co-Authored-By: Claude Fable 5 --- crates/shirabe/src/installer/installer_interface.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/shirabe/src/installer/installer_interface.rs') diff --git a/crates/shirabe/src/installer/installer_interface.rs b/crates/shirabe/src/installer/installer_interface.rs index ff7708f1..3394f1e3 100644 --- a/crates/shirabe/src/installer/installer_interface.rs +++ b/crates/shirabe/src/installer/installer_interface.rs @@ -11,57 +11,57 @@ pub trait InstallerInterface: std::fmt::Debug { fn supports(&self, package_type: &str) -> bool; fn is_installed( - &mut self, + &self, repo: &dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, ) -> bool; async fn download( - &mut self, + &self, package: PackageInterfaceHandle, prev_package: Option, ) -> anyhow::Result>; async fn prepare( - &mut self, + &self, r#type: &str, package: PackageInterfaceHandle, prev_package: Option, ) -> anyhow::Result>; async fn install( - &mut self, + &self, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, ) -> anyhow::Result>; async fn update( - &mut self, + &self, repo: &mut dyn InstalledRepositoryInterface, initial: PackageInterfaceHandle, target: PackageInterfaceHandle, ) -> anyhow::Result>; async fn uninstall( - &mut self, + &self, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, ) -> anyhow::Result>; async fn cleanup( - &mut self, + &self, r#type: &str, package: PackageInterfaceHandle, prev_package: Option, ) -> anyhow::Result>; - fn get_install_path(&mut self, package: PackageInterfaceHandle) -> Option; + fn get_install_path(&self, package: PackageInterfaceHandle) -> Option; - fn as_binary_presence_interface(&mut self) -> Option<&mut dyn BinaryPresenceInterface> { + fn as_binary_presence_interface(&self) -> Option<&dyn BinaryPresenceInterface> { None } - fn as_plugin_installer_mut(&mut self) -> Option<&mut PluginInstaller> { + fn as_plugin_installer(&self) -> Option<&PluginInstaller> { None } } -- cgit v1.3.1