Skip to content

perf: deduplicate CPU profile name conversions - #418

Merged
IlyasShabi merged 3 commits into
mainfrom
ishabi/deduplicate-name-conversion
Sep 29, 2026
Merged

IlyasShabi merged 3 commits into
mainfrom
ishabi/deduplicate-name-conversion

Conversation

@IlyasShabi

@IlyasShabi IlyasShabi commented Sep 28, 2026 •

Copy link
Copy Markdown

Summary

This PR removes repeated V8 name conversions during eager CPU-profile translation.

Function names, script names, and script IDs are now retrieved once per profile node and reused for its line ticks and child nodes.
This avoids repeated UTF-8 decoding and V8 string-table lookups without adding a persistent cache.

Benchmark

A was added in benchmark/name-caching.js. Local measurements showed improvements of up to 17%, depending on the profile shape.

@IlyasShabi IlyasShabi added the semver-patch Bug or security fixes, mainly label Sep 28, 2026
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Overall package size

Self size: 2.6 MB
Deduped: 3.31 MB
No deduping: 3.31 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | pprof-format | 2.3.1 | 504.33 kB | 504.33 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

@datadog-prod-us1-6

This comment has been minimized.

szegedi
szegedi previously approved these changes Sep 28, 2026

@szegedi szegedi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great little optimization! It must reduce memory usage as well, right, as there'll be fewer duplicate strings around? I presume V8 under the hood doesn't really do anything to avoid that.

@IlyasShabi

Copy link
Copy Markdown
Author

@szegedi Thanks! I also reused the function name, script name, and script ID across child nodes and this increased the local improvement to up to 17% 🎉
On another hand for the heap profiler, V8 already deduplicates these strings, so this mainly saves repeated UTF-8 conversions and lookups.
I recently fixed a similar issue in V8's heap profiler: https://chromium-review.googlesource.com/c/v8/v8/+/8449311

@szegedi szegedi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@IlyasShabi
IlyasShabi merged commit 19f8686 into main Sep 29, 2026
70 checks passed
@IlyasShabi
IlyasShabi deleted the ishabi/deduplicate-name-conversion branch September 29, 2026 12:24
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.

2 participants