Skip to content

perf(pprof): reuse sample labels before allocating - #443

Open
BridgeAR wants to merge 2 commits into
mainfrom
BridgeAR/2026-11-19-label-cache
Open

BridgeAR wants to merge 2 commits into
mainfrom
BridgeAR/2026-11-19-label-cache

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

Repeated labels such as thread names allocate a Label for each sample, even when the serializer already has a matching object. Check the per-profile cache before allocating so one pass builds the label array without changing which objects are shared.

Replaying a 5,972-sample wall profile with the locked pprof-format dependency on Node 26 reduced profile construction from 2.32 ms to 2.13 ms (8%). Construction plus the synchronous part of encodeAsync() fell from 4.53 ms to 4.32 ms (5%). The encoded bytes match.

How to test the change? Run the profile serializer tests. The label test checks that cache hits share objects without changing label values or order.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Overall package size

Self size: 3.02 MB
Deduped: 4.14 MB
No deduping: 4.14 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 19, 2026
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-11-19-label-cache branch from 80c04e7 to 32ec845 Compare November 25, 2026 15:14
@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Pipelines

❌ Errors

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

🚦 1 Pipeline job failed

DataDog/apm-reliability/pprof-nodejs | benchmarks-pr-comment

View more details · View in GitLab

Useful? React with 👍 / 👎

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

Repeated labels such as thread names allocate a Label for each sample, even when the serializer already has a matching object. Check the per-profile cache before allocating so one pass builds the label array without changing which objects are shared.

Replaying a 5,972-sample wall profile with the locked pprof-format dependency on Node 26 reduced profile construction from 2.32 ms to 2.13 ms (8%). Construction plus the synchronous part of encodeAsync() fell from 4.53 ms to 4.32 ms (5%). The encoded bytes match.
V8 can grant 12 MiB of automatic headroom. The restoration fixture
requires an increase greater than 16 MiB, so it keeps allocating until
V8 aborts before the test can release the retained objects.
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-11-19-label-cache branch from e52c6db to 4af191d Compare November 25, 2026 17:23
@BridgeAR
BridgeAR marked this pull request as ready for review November 25, 2026 17:40

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