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/tests/installer/library_installer_test.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/tests/installer/library_installer_test.rs') diff --git a/crates/shirabe/tests/installer/library_installer_test.rs b/crates/shirabe/tests/installer/library_installer_test.rs index f2a94cbf..b9e3caa8 100644 --- a/crates/shirabe/tests/installer/library_installer_test.rs +++ b/crates/shirabe/tests/installer/library_installer_test.rs @@ -196,7 +196,7 @@ fn test_installer_creation_should_not_create_bin_directory() { #[test] fn test_is_installed() { let mut setup = set_up(); - let mut library = + let library = LibraryInstaller::new(setup.io.clone(), setup.composer.clone(), None, None, None); let package = get_package("test/pkg", "1.0.0"); @@ -237,7 +237,7 @@ fn test_install() { .returning(|_, _| Ok(None)); set_download_manager(&setup, dm); - let mut library = + let library = LibraryInstaller::new(setup.io.clone(), setup.composer.clone(), None, None, None); let mut repository = InstalledArrayRepository::new().unwrap(); @@ -296,7 +296,7 @@ fn test_update() { repository.add_package(initial.clone()).unwrap(); // The default Filesystem is fine; the LibraryInstaller's own filesystem performs the rename. - let mut library = + let library = LibraryInstaller::new(setup.io.clone(), setup.composer.clone(), None, None, None); run(library.update(&mut repository, initial.clone(), target.clone())).unwrap(); @@ -344,7 +344,7 @@ fn test_uninstall() { .returning(|_, _| Ok(None)); set_download_manager(&setup, dm); - let mut library = + let library = LibraryInstaller::new(setup.io.clone(), setup.composer.clone(), None, None, None); // PHP mocks hasPackage to return (true, false) over two calls; a real repository @@ -366,7 +366,7 @@ fn test_uninstall() { #[test] fn test_get_install_path_without_target_dir() { let mut setup = set_up(); - let mut library = + let library = LibraryInstaller::new(setup.io.clone(), setup.composer.clone(), None, None, None); let package = get_package("Vendor/Pkg", "1.0.0"); @@ -381,7 +381,7 @@ fn test_get_install_path_without_target_dir() { #[test] fn test_get_install_path_with_target_dir() { let mut setup = set_up(); - let mut library = + let library = LibraryInstaller::new(setup.io.clone(), setup.composer.clone(), None, None, None); let package = get_package("Foo/Bar", "1.0.0"); package.__set_target_dir(Some("Some/Namespace".to_string())); -- cgit v1.3.1