Skip to content

Speed up source map emit for large single-line object literals - #64138

Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-source-map-emit-slow
Draft

Speed up source map emit for large single-line object literals#64138
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-source-map-emit-slow

Conversation

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Source map emit repeatedly recalculated the generated UTF-16 column from the start of the current line. Files containing large single-line object literals therefore incurred quadratic scanning costs.

  • Writer optimization

    • Cache the last measured output position and UTF-16 column.
    • Scan only text appended since the previous lookup.
    • Reset cached state when output advances to a new line.
  • Coverage

    • Validate incremental UTF-16 accounting with astral characters.
    • Validate cache resets across raw newlines and indented lines.

@typescript-automation typescript-automation Bot added For Milestone Bug PRs that fix a bug with a specific milestone labels Sep 2, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Milestone Bug PRs that fix a bug with a specific milestone labels Sep 2, 2026
Copilot AI and others added 2 commits September 2, 2026 22:17
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix sourceMap emit performance for large object literals Speed up source map emit for large single-line object literals Sep 2, 2026
@jakebailey

Copy link
Copy Markdown
Member

Interesting, I think we have this same optimization somewhere else? I had thought for this specifically, actually.

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

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sourceMap emit is disproportionately slow for files containing one very large object literal

3 participants