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 unreasonably slow bundle time on sourcemaps with long lines #2228

Merged
merged 1 commit into from
May 30, 2018

Conversation

mourner
Copy link
Contributor

@mourner mourner commented May 29, 2018

Fixes #1553. Fixes #1700.

For some builds like in the issues above, traceSegment in collapseSourcemaps.ts took unreasonably long time because some of the source maps contained very long lines (e.g. one example line had 50k segments), and linearly searching through them for every segment that needed tracing was too slow. This PR switches traceSegment to use simple binary search, fixing the issue.

Bundle times for the repro case in #1553:

  • sourceMap: false (master rollup): 2.1s
  • sourceMap: true (master rollup): 15.5s
  • sourceMap: true (this branch): 2.4s

cc @lukastaegert

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

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

Nice work! MagicString might also benefit from some binary searches on hot paths.

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

Great work again!

j = m - 1;
} else {
i = m + 1;
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

@lukastaegert lukastaegert merged commit 99ceb0b into rollup:master May 30, 2018
@lukastaegert lukastaegert added this to the 0.60.0 milestone May 30, 2018
@mourner mourner deleted the fast-sourcemap-long-lines branch May 30, 2018 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build takes about 2-3 minutes Sourcemap true/'inline' significantly increases bundle time
3 participants