less / less/less.js

SourceMap generation is unnecessarily slow

Open
#2,828 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request up-for-grabs
Dominant language
JavaScript
Stars
17k
Forks
3.4k
Avg merge
7h 42m
Merged PRs (30d)
26

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/less/source-map-output.js at SourceMapOutput#add, especially the line linked in the issue, and profile the build to confirm the repeated source-file splitting. Done means source-map generation no longer repeatedly processes the same file and the build is measurably faster; compare the result with the reported 15s versus 5s build times.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.