perf: deduplicate CPU profile name conversions - #418
Conversation
Overall package sizeSelf size: 2.6 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 |
This comment has been minimized.
This comment has been minimized.
szegedi
left a comment
There was a problem hiding this comment.
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.
|
@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% 🎉 |
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.