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

(perf) - Improve performance of simplify by removing traversal for type inference #778

Merged
merged 1 commit into from
Jan 15, 2018

Conversation

vigneshshanmugam
Copy link
Member

@vigneshshanmugam vigneshshanmugam commented Jan 15, 2018

  • Yields around 1 - 1.5 seconds on average for files around 2MB. Gets better for files > 2MB

This PR handles the type information that is lost due to sequence expression transformation in Simplify plugin. It takes a different approach instead of traversing all of the identifiers for type information.

Before

pluginAlias                             time(ms) # visits time/visit(ms)
// Run 1
minify-simplify                         6090.013 278330   0.022
transform-simplify-comparison-operators 41.059   18348    0.002
// Run 2
minify-simplify                         6029.847 278330   0.022
transform-simplify-comparison-operators 46.415   18348    0.003
// Run 3
minify-simplify                         6045.218 278330   0.022
transform-simplify-comparison-operators 44.464   18348    0.002

After

// 1
minify-simplify                         4617.782 278330   0.017
transform-simplify-comparison-operators 122.181  18348    0.007
// 2
minify-simplify                         4718.766 278330   0.017
transform-simplify-comparison-operators 122.642  18348    0.007
// 3
minify-simplify                         4447.601 278330   0.016
transform-simplify-comparison-operators 127.682  18348    0.007

The type inference is based on the Babel inference.

  • Only for identifiers we take the different path

@vigneshshanmugam vigneshshanmugam changed the title (perf) - Improve performance of simplify by removing traversal (perf) - Improve performance of simplify by removing traversal for type inference Jan 15, 2018
@vigneshshanmugam vigneshshanmugam added perf Topics related to Performance Tag: Polish Pull Request for formatting, style changes, code cleanups, comments etc... labels Jan 15, 2018

if (
!t.isAnyTypeAnnotation(leftTypes) &&
t.isFlowBaseAnnotation(leftTypes)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this affects the babel-7 upgrade. I think we should test this against Babel7. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

@boopathi boopathi merged commit ab81368 into master Jan 15, 2018
@boopathi boopathi deleted the perf-2 branch January 15, 2018 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf Topics related to Performance Tag: Polish Pull Request for formatting, style changes, code cleanups, comments etc...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants