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

Cache parsed path mapping patterns #44078

Merged
merged 4 commits into from May 26, 2021
Merged

Cache parsed path mapping patterns #44078

merged 4 commits into from May 26, 2021

Conversation

@amcasey
Copy link
Member

@amcasey amcasey commented May 13, 2021

If a project has many of them (e.g. 1800), parsing the patterns repeatedly can take up a lot of time.

Specifically, getOwnKeys and hasZeroOrOneAsteriskCharacter were showing up as self-time hotspots.

@amcasey amcasey marked this pull request as ready for review May 19, 2021
src/compiler/moduleNameResolver.ts Outdated Show resolved Hide resolved
src/compiler/moduleNameResolver.ts Outdated Show resolved Hide resolved
@@ -6732,14 +6732,25 @@ namespace ts {
return <T>changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false);
}

export function tryParsePattern(pattern: string): Pattern | undefined {
// This should be verified outside of here and a proper error thrown.
Debug.assert(hasZeroOrOneAsteriskCharacter(pattern));

This comment has been minimized.

@sheetalkamat

sheetalkamat May 21, 2021
Member

Why did we remove the assert or requirement that users of this have this checked already?

This comment has been minimized.

@amcasey

amcasey May 21, 2021
Author Member

The check was duplicated between the caller and the assert (none needed it for other reasons - they were just doing it to satisfy this requirement). I didn't think the requirement made the API conceptually clearer or the implementation simpler - on the contrary, I thought it was preferable to gather all the checks into a single function.

This comment has been minimized.

@amcasey

amcasey May 25, 2021
Author Member

Perhaps your question was "what happened to the proper error?". It's still there - an undefined result now indicates that an error should be reported.

@sandersn sandersn added this to Not started in PR Backlog May 24, 2021
@sandersn sandersn moved this from Not started to Waiting on author in PR Backlog May 24, 2021
amcasey added 2 commits May 13, 2021
If a project has many of them (e.g. 1800), parsing the patterns
repeatedly can take up a lot of time.
@amcasey amcasey force-pushed the amcasey:PathPatterns branch from 8a89af5 to 00b9ccd May 25, 2021
@amcasey
Copy link
Member Author

@amcasey amcasey commented May 25, 2021

Force push is a rebase onto master. Updates to follow.

@amcasey
Copy link
Member Author

@amcasey amcasey commented May 26, 2021

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented May 26, 2021

Heya @amcasey, I've started to run the tarball bundle task on this PR at 0435303. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented May 26, 2021

Hey @amcasey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/103950/artifacts?artifactName=tgz&fileId=5B3FB4B8589F2D1B2AB57D830882879C2CC6FD618829A38998245D6627FCD24802&fileName=/typescript-4.4.0-insiders.20210526.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@4.4.0-pr-44078-3".;

PR Backlog automation moved this from Waiting on author to Needs merge May 26, 2021
@amcasey amcasey merged commit 3ffa245 into microsoft:master May 26, 2021
9 checks passed
9 checks passed
@github-actions
build (10.x)
Details
@github-actions
CodeQL-Build
Details
@github-actions
build (12.x)
Details
@github-actions
build (14.x)
Details
@github-code-scanning
CodeQL No new or fixed alerts
Details
@microsoft-cla
license/cla All CLA requirements met.
Details
@azure-pipelines
node10 Build #103926 succeeded
Details
@azure-pipelines
node12 Build #103924 succeeded
Details
@azure-pipelines
node14 Build #103925 succeeded
Details
PR Backlog automation moved this from Needs merge to Done May 26, 2021
@amcasey amcasey deleted the amcasey:PathPatterns branch May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PR Backlog
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants