Skip to content

Don’t poll the index for unit changes on every filesDidChange call #2003

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

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Feb 25, 2025

pollForUnitChangesAndWait is a costly operation since it iterates through all the unit files on the file system. We should only run it during initial indexing (where we might need to build the initial indexstore-db) but not for any subsequent indexing calls.

`pollForUnitChangesAndWait` is a costly operation since it iterates through all the unit files on the file system. We should only run it during initial indexing (where we might need to build the initial indexstore-db) but not for any subsequent indexing calls.
@ahoppen
Copy link
Member Author

ahoppen commented Feb 25, 2025

@swift-ci Please test

// potentially not knowing about unit files, which causes the corresponding source files to be re-indexed.
index.pollForUnitChangesAndWait()
if ensureAllUnitsRegisteredInIndex {
index.pollForUnitChangesAndWait()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add some additional documentation to pollForUnitChangesAndWait to describe what it actually does (and the fact it's costly) rather than just "for testing"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I’ll add some to indexstore-db

@ahoppen ahoppen enabled auto-merge February 26, 2025 04:25
@ahoppen ahoppen merged commit c311e1b into swiftlang:main Feb 26, 2025
3 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