Skip to content

SourceMap generation is unnecessarily slow #2828

Open

Description

@nicks

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?

Activity

  1. matthew-dean commented on Mar 1, 2016

    @matthew-dean
    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.

  2. seven-phases-max commented on Mar 25, 2016

    @seven-phases-max
    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...

  3. nicks commented on Mar 25, 2016

    @nicks
    Author

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

  4. seven-phases-max commented on Mar 25, 2016

    @seven-phases-max
    Member

    Ah, thank you!

  5. matthew-dean commented on May 9, 2016

    @matthew-dean
    Member

    Re-opened due to reversion of #2834.

  6. nicks commented on May 31, 2016

    @nicks
    Author

    re-tried as #2903

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions