From bebe070bda715b9f5167739c64d262aa749cc372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brian=20Sch=C3=A4ffner?= Date: Fri, 23 Oct 2026 23:48:35 +0200 Subject: [PATCH] perf(discovery): skip composer.json probes for manifest-cached packages On a manifest cache hit every package's composer.json was still stat()ed before its cached metadata was used, although the manifest fingerprint check had just validated the same file. Probe the filesystem only for files the manifest does not know. --- src/Discovery/BundleDiscovery.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Discovery/BundleDiscovery.php b/src/Discovery/BundleDiscovery.php index 503e196..1cf8c9c 100644 --- a/src/Discovery/BundleDiscovery.php +++ b/src/Discovery/BundleDiscovery.php @@ -126,7 +126,7 @@ private function composerBundle(string $packageName): ?BundleMetadata $composerFile = sprintf('%s/composer.json', $installPath); - if (!is_file($composerFile)) { + if (!$this->knownComposerFile($composerFile)) { return null; } @@ -457,7 +457,7 @@ private function requirementsActive(array $requirements): bool $composerFile = sprintf('%s/composer.json', $installPath); - if (!is_file($composerFile)) { + if (!$this->knownComposerFile($composerFile)) { return false; } @@ -503,6 +503,15 @@ private function kernelRequirements(mixed $kernel): array ); } + /** + * Metadata restored from the manifest cache was validated against the file's + * fingerprint already; only unknown files need a filesystem probe. + */ + private function knownComposerFile(string $composerFile): bool + { + return isset($this->metadata[$composerFile]) || is_file($composerFile); + } + /** @return array */ private function composerMetadata(string $composerFile): array {