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

Improve generator performance #3283

Merged
merged 6 commits into from Jan 22, 2016
Merged

Improve generator performance #3283

merged 6 commits into from Jan 22, 2016

Conversation

gzzhanghao
Copy link
Contributor

This PR aims to fix the performance issue for babel-generator, see T6884.

Here is the result from the same app in the discussion.

===== Origin =====
babylon 265
babel generator 2238
acorn 107
escodegen 355
esprima 95
escodegen 322
===== Optimized =====
babylon 296
babel generator 662
acorn 113
escodegen 355
esprima 106
escodegen 317

@gzzhanghao gzzhanghao changed the title Improve generator performance T6884 Improve generator performance Jan 19, 2016
@codecov-io
Copy link

Current coverage is 85.12%

Merging #3283 into master will decrease coverage by -0.18% as of e9fae4c

@@            master   #3283   diff @@
======================================
  Files          215     215       
  Stmts        15751   15703    -48
  Branches      3373    3360    -13
  Methods          0       0       
======================================
- Hit          13436   13367    -69
- Partial        679     694    +15
- Missed        1636    1642     +6

Review entire Coverage Diff as of e9fae4c

Powered by Codecov. Updated on successful CI builds.

* Find a token between start and end.
*/

_findToken(test, start, end) {
Copy link
Member

Choose a reason for hiding this comment

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

can you add type annotations?

@amasad
Copy link
Member

amasad commented Jan 20, 2016

This is awesome! I'm excited for this. Mostly looks good just a couple of suggestions/questions

@amasad
Copy link
Member

amasad commented Jan 20, 2016

ok, will merge tomorrow. Do you have any more ideas for optimizations? (this is awesome)

@gzzhanghao
Copy link
Contributor Author

@amasad not now, but I'll keep finding performance issues in the code base : )

@hzoo
Copy link
Member

hzoo commented Jan 20, 2016

Maybe we should add some perf metrics whenever we updated some of the packages like babylon/babel-generator like in https://phabricator.babeljs.io/T6884#70050?

Unless we want to bring in a larger file, the largest built file we have is babel-polyfill/dist/polyfill

@gzzhanghao
Copy link
Contributor Author

@hzoo agree, we can add some identity test case and measure the running time for each package. like escodegen's identity test

@hzoo hzoo added the PR: Polish 💅 A type of pull request used for our changelog categories label Jan 20, 2016
@sebmck
Copy link
Contributor

sebmck commented Jan 22, 2016

Thank you @gzzhanghao, you're amazing!

@hzoo
Copy link
Member

hzoo commented Jan 22, 2016

Would it be possible to run a perf.js test on a PR (would be cool to get a comment on the PR like code coverage)? Or we could do it in between releases too.

We can test the parser on different files/libraries, and then the generation?

@robcolburn
Copy link
Contributor

Since we are using array-style access on a string, do we need worry about multi-byte characters, ex: Chinese, Emoji.

I'm not super familiar with Babel's code-base, so that may already be broken, or not something we need to concern ourselves with. A test would be great, if we don't have one yet.

@amasad
Copy link
Member

amasad commented Jan 22, 2016

Rob: good point, can you please follow up with a task?
@hzoo: great idea! Build it :)

@hzoo
Copy link
Member

hzoo commented Jan 22, 2016

@robcolburn if we don't have a test for it already we'd appreciate a PR for some!

@robcolburn
Copy link
Contributor

@hzoo I didn't see a test for it, so I PR'd a few to @gzzhanghao branch - https://github.com/gzzhanghao/babel/pull/1

@amasad
Copy link
Member

amasad commented Jan 22, 2016

@robcolburn Thanks, going to merge this, so can you PR to master instead?

amasad added a commit that referenced this pull request Jan 22, 2016
Improve generator performance
@amasad amasad merged commit 7d719d9 into babel:master Jan 22, 2016
@robcolburn
Copy link
Contributor

@amasad done #3299

@gzzhanghao gzzhanghao deleted the gen-perf branch March 6, 2016 07:44
@babel-bot babel-bot mentioned this pull request Sep 7, 2016
19 tasks
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: perf outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants