Enhance path resolution caching#34
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances path resolution caching in the resolver to better balance performance with freshness when the filesystem changes.
Changes:
- Added a TTL-based expiration to the resolved-path cache.
- Split caching into two layers: parsed candidate paths (cache until document changes) and filesystem-resolved paths (cache with TTL).
- Updated
Documentto store the two caches separately and reset them on content changes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/resolver/mod.rs |
Introduces TTL constant and updates ResolvedPathCache to include creation time for expiration. |
src/resolver/collect.rs |
Implements TTL-aware cache lookup and adds candidate-path caching to avoid reparsing. |
src/document/mod.rs |
Replaces the old single tokens cache with separate candidate/resolved caches on Document. |
CHANGELOG.md |
Documents the new TTL behavior for resolved path caching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else { | ||
| // miss | ||
| let path_candidates: Arc<Vec<Vec<PathCandidate>>> = | ||
| Arc::new(parse_document(document).into_iter().flatten().collect()); |
Comment on lines
+20
to
25
| let mut cache = document.resolved_path.lock().await; | ||
| let signature = config.signature()?; | ||
| if let Some(tokens) = &cache.tokens | ||
| if let Some(cache) = &*cache | ||
| && cache.config_signature == signature | ||
| && cache.created_at.elapsed() < RESOLVE_CACHE_TTL | ||
| { |
Comment on lines
+22
to
+25
| /// This will never expired until the document content changes | ||
| pub candidate_path: Mutex<Option<Arc<Vec<Vec<PathCandidate>>>>>, | ||
| /// Cached exists paths (resolved from candidate paths) | ||
| /// This may expired to avoid file system change |
|
|
||
| ### Added | ||
| - Added new step to release workflow to publish to crates.io. | ||
| - Added TTL to resolved path cache to keep path highlighting update with file system changes. |
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.
No description provided.