Skip to content

trace-mapping is slow for maps from minified sources #41

@connor4312

Description

@connor4312
  1. Take this sourcemap Archive.zip (from https://github.com/vaclavHala/slow-sourcemaps) which contains a sourcemap from a large minified source
  2. generatedPositionFor the source ../src/extension.ts
  3. It takes 24 seconds 🩸
const { TraceMap, generatedPositionFor } = require('./');
const src = require('fs').readFileSync('/Users/connor/Downloads/slow-sourcemaps/dist/extension.js.map', 'utf-8');

const tm = new TraceMap(JSON.parse(src));

const start = Date.now();
generatedPositionFor(tm, {source: '../src/extension.ts', line: 6, column: 0, bias: 1});
console.log('took', Date.now() - start);

Debugging through it, this looks like a pathological case of inserting 13k items into a massive line (for the minified source)

Image

CPU profile: vscode-profile-2025-09-09-10-24-35.cpuprofile.txt

Originally reported on microsoft/vscode-js-debug#2265

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions