-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dedicated cache directory per ruff version #8333
Dedicated cache directory per ruff version #8333
Conversation
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
@@ -102,9 +101,8 @@ impl Cache { | |||
pub(crate) fn open(package_root: PathBuf, settings: &Settings) -> Self { | |||
debug_assert!(package_root.is_absolute(), "package root not canonicalized"); | |||
|
|||
let mut buf = itoa::Buffer::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using itoa
to write a single number felt overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we still automatically clear old entries with this approach?
PR Check ResultsEcosystem✅ ecosystem check detected no linter changes. ✅ ecosystem check detected no format changes. |
We continue to automatically clear old file entries, the same as the old version. What the version doesn't (nor did the baseline) is to clean up caches of old versions (except if you run |
Oh interesting, so even the existing cache will never remove files from old versions? |
Not as far as I know. The only cleanup code that I see is the removal of stale entries: ruff/crates/ruff_cli/src/cache.rs Lines 192 to 197 in 6199590
But there's no operation that iterates over all files and cleans unused entries, other than the |
Summary
This PR changes our cache to use a dedicated cache directory per ruff version.
.ruff_cache/content
.ruff_cache/0.1.3
The motivation is that I want to rule out that hash collisions between cache keys causing ruff to load a cache created by another version.
Loading incompatible caches might be the root cause for #8147 (although unlikely, because users mention that they didn't upgrade ruff)
Other hash collissions are less problematic, because the Cache checks if the loaded file is for the same package, and otherwise clears the cache for that package.
Open questions
I'm unsure if this is considered a breaking change or not. It does change observable behavior of Ruff but we never included it in our public API.
Test Plan
Verified that the cache is still used by comparing performance before/after