Skip to content

Allow cancellation during extract method's symbol walking #18121

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
Aug 30, 2017

Conversation

amcasey
Copy link
Member

@amcasey amcasey commented Aug 29, 2017

...since it's potentially expensive.

@msftclas
Copy link

@amcasey,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@@ -158,6 +162,10 @@ namespace ts {
}

function visitSymbol(symbol: Symbol): boolean {
if (cancellationToken) {
Copy link
Member

Choose a reason for hiding this comment

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

I have 2 fairly ignorant questions

  • Are cancellation checks expensive (I seem to recall that it's based on checking a named pipe, which sounds scary)? Is it throttled?
  • How many times do we expect visitSymbol to be called in a "typical" operation?

I guess the overall question I'm asking is whether you're fairly sure this check isn't a performance burden.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

@billti billti Aug 29, 2017

Choose a reason for hiding this comment

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

FYI: Some crude overhead measurements from back when I prototyped this: https://github.com/billti/cancellation#overhead . Definitely use the throttling mechanism. We've seen significant perf regressions when this wasn't done in prior cancellation checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

As Vlad said, cancellation checks are throttled. Having said that, I don't have a sense of how expensive cancellability is.

@@ -932,7 +933,8 @@ namespace ts.refactor.extractMethod {
scopes: Scope[],
enclosingTextRange: TextRange,
sourceFile: SourceFile,
checker: TypeChecker) {
checker: TypeChecker,
cancellationToken: CancellationToken) {
Copy link
Member

Choose a reason for hiding this comment

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

With the other changes, I don't think this argument is used anywhere anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you mean cancellationToken, I believe it is closed over in the accept lambda below.

Copy link
Member

Choose a reason for hiding this comment

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

@amcasey Ack, sorry, thought I was reading a different file here. Nevermind. All good.

@amcasey
Copy link
Member Author

amcasey commented Aug 29, 2017

Per @weswigham's suggestion, handle cancellation in the Accept predicate, rather than adding a new SymbolWalker API.

@@ -932,7 +933,8 @@ namespace ts.refactor.extractMethod {
scopes: Scope[],
enclosingTextRange: TextRange,
sourceFile: SourceFile,
checker: TypeChecker) {
checker: TypeChecker,
cancellationToken: CancellationToken) {
Copy link
Member

Choose a reason for hiding this comment

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

@amcasey Ack, sorry, thought I was reading a different file here. Nevermind. All good.

@amcasey amcasey changed the title Make SymbolWalker cancellable Allow cancellation during extract method's symbol walking Aug 30, 2017
@amcasey amcasey merged commit 27e590d into microsoft:master Aug 30, 2017
@amcasey amcasey deleted the WalkerCancel branch August 30, 2017 00:24
amcasey added a commit to amcasey/TypeScript that referenced this pull request Sep 15, 2017
Allow cancellation during extract method's symbol walking
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants