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

Fix perf issue in typescript parser plugin #8792

Merged
merged 1 commit into from Oct 1, 2018

Conversation

@matthewrobertson
Copy link
Contributor

matthewrobertson commented Oct 1, 2018

Q                       A
Fixed Issues? Fixes #8779
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? N/A
Documentation PR Link N/A
Any Dependency Changes? No
License MIT

This commit fixes a perf regression introduced by 8ee24fd. Throwing an
exception in tsTryParseAndCatch is expensive. We can avoid it in the
common case by moving the conditional outside of the callback passed
to tsTryParseAndCatch.

Matthew Robertson
This commit fixes a perf regression introduced by 8ee24fd. Throwing an
exception in `tsTryParseAndCatch` is expensive. We can avoid it in the
common case by moving the conditional outside of the callback passed
to `tsTryParseAndCatch`.
@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Oct 1, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9197/

@matthewrobertson

This comment has been minimized.

Copy link
Contributor Author

matthewrobertson commented Oct 1, 2018

I set up a little demo to profile the typescript parser here: https://github.com/matthewrobertson/babel-parser-perf

Before this change adding the typescript plugin made the parser much slower:

> node ./index.js ./some-code-to-parse.js

Normal parse: 169.068ms
Typescript parse: 10823.573ms

After this change parsing takes close to the same amount of time:

> node ./index.js ./some-code-to-parse.js

Normal parse: 155.450ms
Typescript parse: 227.296ms
@andy-ms
andy-ms approved these changes Oct 1, 2018
@existentialism existentialism merged commit 07862e7 into babel:master Oct 1, 2018
4 checks passed
4 checks passed
babel/repl REPL preview is available
Details
ci/circleci Your tests passed on CircleCI!
Details
codecov/project 80.55% (target 80%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@existentialism

This comment has been minimized.

Copy link
Member

existentialism commented Oct 1, 2018

@matthewrobertson thanks!

@lock lock bot added the outdated label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants
You can’t perform that action at this time.