Skip to content

Deduplicate watched file events, avoid MatchesFileName #1308

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jakebailey
Copy link
Member

These are two tactics which I think will help with #1265.

I've noticed that VS Code can send duplicate events; deduplicate them before handling.

Also, we can avoid the expensive MatchesFileName call if the config file entry is already pending, hopefully saving even more time.

Copy link
Contributor

@Copilot 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 aims to reduce redundant file event processing and improve performance by skipping unnecessary filename matching when a config entry is already pending reload.

  • Deduplicate incoming FileEvent entries before handling them.
  • Update ConfigFileRegistry to avoid expensive MatchesFileName calls if a reload is already pending.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/project/service.go Added sorting and compaction logic in OnWatchedFilesChanged to deduplicate events
internal/project/configfileregistry.go Refactored tryInvokeWildCardDirectories to only call MatchesFileName once per entry
Comments suppressed due to low confidence (2)

internal/project/service.go:302

  • Consider adding unit tests for OnWatchedFilesChanged to verify that duplicate FileEvent entries are properly deduplicated.
		deduped := slices.Clone(changes)

internal/project/configfileregistry.go:242

  • Add tests for tryInvokeWildCardDirectories to ensure that MatchesFileName is skipped when pendingReload is not PendingReloadNone and that SetPendingReload behaves correctly.
		hasSet := false

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