Skip to content

perf(cli): don't drop file guard and reuse data#10731

Merged
ematipico merged 2 commits into
mainfrom
perf/optimisations
Jun 24, 2026
Merged

perf(cli): don't drop file guard and reuse data#10731
ematipico merged 2 commits into
mainfrom
perf/optimisations

Conversation

@ematipico

Copy link
Copy Markdown
Member

Summary

Two small optimisations written with an AI agent:

  • Don't drop the WorkspaceGuard if the file exists in the workspace.
  • Re-use the result of FeaturesSupported during scanning.

Test Plan

Added new tests. Green CI.
No changeset since this is just an internal change.

Docs

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 382ae56

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added A-CLI Area: CLI A-Project Area: project labels Jun 22, 2026
@ematipico ematipico changed the title perf: don't drop file guard perf(cli): don't drop file guard and reuse data Jun 22, 2026
@ematipico ematipico requested review from a team June 22, 2026 12:53
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The PR introduces a borrowed constructor for FileGuard in workspace.rs that sets a close_on_drop flag to false, preventing the RAII guard from closing the underlying workspace file on drop. Building on this, a file_features cache (papaya::HashMap<BiomePath, FeaturesSupported>) is added to CrawlerOptions, exposed via two new CrawlerContext trait methods. Handler::can_handle now populates this cache when a file is accepted, and process_file::execute reads from the cache before falling back to a full workspace query. WorkspaceFile::new also uses the borrowed guard for files that already exist in the workspace. Tests are added across workspace.tests.rs, scanner.tests.rs, and process_file.rs.

Suggested labels

A-CLI, A-Project

Suggested reviewers

  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly outlines both optimisations (FileGuard and FeaturesSupported caching), acknowledges AI assistance per guidelines, and explains the test coverage and zero user-facing impact.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately captures both optimizations: preventing unnecessary file guard drops and reusing computed feature data, which are the core changes across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/optimisations

Comment @coderabbitai help to get the list of available commands and usage tips.

@ematipico ematipico merged commit 8f9dec8 into main Jun 24, 2026
29 checks passed
@ematipico ematipico deleted the perf/optimisations branch June 24, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant