Skip to content

perf(sourcemap): resolve profile source maps on demand - #453

Draft
BridgeAR wants to merge 2 commits into
mainfrom
BridgeAR/2026-11-30-sampled-source-maps
Draft

BridgeAR wants to merge 2 commits into
mainfrom
BridgeAR/2026-11-30-sampled-source-maps

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

Profiling a large TypeScript build retains a source map consumer for every map
found at startup. A capture usually needs maps for only a fraction of the scripts.

Resolve the sampled positions after capture and release each consumer before
decoding another map. A bounded cache keeps resolved positions for later captures.

A Node 24.20 replay used 38,670 maps and sampled 128 scripts. Startup CPU fell from
20.9 seconds to under 1 ms. Retained JS heap fell from 1,727 MiB to 0.9 MiB, with
identical pprof bytes.

Refs: #445

Profiling a large TypeScript build retains a source map consumer for
every map found at startup. A capture usually needs maps for only a
fraction of the scripts.

Resolve the sampled positions after capture and release each consumer
before decoding another map. A bounded cache keeps resolved positions
for later captures.

A Node 24.20 replay used 38,670 maps and sampled 128 scripts. Startup CPU
fell from 20.9 seconds to under 1 ms. Retained JS heap fell from
1,727 MiB to 0.9 MiB, with identical pprof bytes.

Refs: #445
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Overall package size

Self size: 3.15 MB
Deduped: 4.28 MB
No deduping: 4.28 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | pprof-format | 2.4.1 | 924.37 kB | 924.37 kB | | source-map | 0.8.0 | 185.66 kB | 185.66 kB | | node-gyp-build | 4.8.4 | 13.86 kB | 13.86 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@BridgeAR BridgeAR added the semver-patch Bug or security fixes, mainly label Nov 30, 2026
One unmapped frame can make the first export read and parse every
map under the application root. Limit discovery to the sampled
script's annotation and adjacent sidecar. Cache definitive misses
for the mapper's lifetime.

Large maps can stall the application thread during decoding even
when reads are asynchronous. Run large lookups on a worker and
let overlapping captures reuse completed lookups. Clear the worker's
Node options to keep application preloads from holding it open.

V8 reports encoded file URLs for ESM scripts, and compilers encode
paths in annotations. Convert those URLs before filesystem lookups.

Refs: #445
PR-URL: #453
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Pipelines

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

Build | build / win32-test-26 — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

Build | build-successful

View more details · View in GitHub Actions

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: baa6e4a | Docs | View more details | Give us feedback!

This branch has not been deployed

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

Labels

semver-patch Bug or security fixes, mainly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant