Skip to content

Enhance path resolution caching#34

Merged
kunlinglio merged 4 commits into
masterfrom
dev
May 8, 2026
Merged

Enhance path resolution caching#34
kunlinglio merged 4 commits into
masterfrom
dev

Conversation

@kunlinglio
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Document to 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.

Comment thread src/resolver/collect.rs Outdated
} else {
// miss
let path_candidates: Arc<Vec<Vec<PathCandidate>>> =
Arc::new(parse_document(document).into_iter().flatten().collect());
Comment thread src/resolver/collect.rs
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 thread src/document/mod.rs Outdated
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
Comment thread CHANGELOG.md Outdated

### 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.
@kunlinglio kunlinglio merged commit d6a814e into master May 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants