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

SourceMap generation is unnecessarily slow #2828

Open
nicks opened this issue Feb 29, 2016 · 6 comments
Open

SourceMap generation is unnecessarily slow #2828

nicks opened this issue Feb 29, 2016 · 6 comments

Comments

@nicks
Copy link

nicks commented Feb 29, 2016

We recently noticed that if we remove sourcemap generation from our build process, the build speeds up from around 15s -> 5s.

When we ran it through the profiler, we noticed that a lot of time is being spent in SourceMapOutput#add. In particular, every time we add a mapping, it has to iterate through the source file and split it into sourceLines. It does this over and over again for the same file.

https://github.com/less/less.js/blob/master/lib/less/source-map-output.js#L57

are there any plans to speed this up? Would you accept a pull request to fix this?

@matthew-dean
Copy link
Member

it has to iterate through the source file and split it into sourceLines

I noticed this also when I started working with the source code and happened upon the source map generation part. This part of the Less library is extremely inefficient, and line counting could be done at the parsing stage (but probably not without a parser rewrite, I'm guessing). So, yes, definitely, PRs welcome.

@seven-phases-max
Copy link
Member

Yes, the current line counting method did make sense initially since then it was used only once to generate a error, but now it's quite painful (same way it's quite a story if you need to generate a warning pointing to a file/line too). Though the refactoring of all this would need "some" efforts...

@nicks
Copy link
Author

nicks commented Mar 25, 2016

oh we already merged a pr for this. Forgot to close the issue. thanks!

@nicks nicks closed this as completed Mar 25, 2016
@seven-phases-max
Copy link
Member

Ah, thank you!

@matthew-dean
Copy link
Member

Re-opened due to reversion of #2834.

@matthew-dean matthew-dean reopened this May 9, 2016
@nicks
Copy link
Author

nicks commented May 31, 2016

re-tried as #2903

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants