[Caching] Drop MemoryCacheStorage, always use FileCacheStorage - #8354
Merged
Conversation
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously
CacheFactorypickedMemoryCacheStoragein CI andFileCacheStorageelsewhere. The memory storage was meant to skip "wasted IO" of writing cache files that CI never reads again.Benchmark on rector's own
src/(491 files, full rule set,--dry-run, PHP 8.4) shows no speed gain from the memory path:Within a single run,
MemoryCacheStorageis the same speed asFileCacheStoragecold (both do full analysis; the ~484 cache-file writes cost nothing next to analysis time). It just never persists, so every run stays cold. The only real win comes from the file cache on reruns (~7x faster, 3.3 s vs 23 s).So the split added a whole storage class and a
CiDetectorbranch for zero measurable benefit. This dropsMemoryCacheStorageand always usesFileCacheStorage.public function create(): Cache { - // in CI the workspace is ephemeral and usually starts from scratch, - // so a file cache that is never read again is only wasted IO -> use faster in-memory cache - if (new CiDetector()->isCiDetected()) { - return new Cache(new MemoryCacheStorage()); - } - $cacheDirectory = SimpleParameterProvider::provideStringParameter(Option::CACHE_DIR); ... return new Cache(new FileCacheStorage($cacheDirectory, $this->fileSystem)); }