Skip to content
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

[SourceKit] Cancel in-flight builds on editor.close #73323

Merged
merged 6 commits into from May 1, 2024

Conversation

hamishknight
Copy link
Collaborator

@hamishknight hamishknight commented Apr 29, 2024

When closing a document, cancel any in-flight builds happening for it.

rdar://127126348

Comment on lines 2462 to 2464
// Then remove the cached AST if we've been asked to do so.
if (RemoveCache)
Removed->removeCachedAST();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any point to not removing from the cache if we never re-use it anyway? Or is there some case where it is re-used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I mean we probably ought to re-use if the file contents matches after a close/open, but don't currently. I am planning on putting up a patch for that, but I suppose we could unconditionally remove for the time being.

There were a couple of accesses not guarded by
`CacheMtx`, introduce a couple of methods that
guard them, renaming `getASTProducer` while here.

Also make sure we don't ever insert a producer
after it has been purposefully removed by e.g a
close that removes the cached AST.
And move this into the constructor since it only
needs doing once.
This doesn't seem to be required by any of the
tests using it.
When closing a document, cancel any in-flight
builds happening for it.

rdar://127126348
@hamishknight
Copy link
Collaborator Author

After talking with @ahoppen, updated to use an opt-in flag for this behavior

@hamishknight hamishknight changed the title [SourceKit] Cancel in-flight builds on editor.close [SourceKit] Allow cancellation of in-flight builds foreditor.close Apr 30, 2024
@hamishknight
Copy link
Collaborator Author

After further discussion, flipped the default back to true

@hamishknight
Copy link
Collaborator Author

@swift-ci please test

@hamishknight
Copy link
Collaborator Author

@swift-ci please build toolchain

@hamishknight hamishknight changed the title [SourceKit] Allow cancellation of in-flight builds foreditor.close [SourceKit] Cancel in-flight builds on editor.close Apr 30, 2024
@hamishknight hamishknight merged commit 7da91bd into apple:main May 1, 2024
8 checks passed
@hamishknight hamishknight deleted the cancel-on-close branch May 1, 2024 11:07
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.

None yet

3 participants