Reduce time profiler memory usage with lazy profile tree#287
Reduce time profiler memory usage with lazy profile tree#287IlyasShabi wants to merge 8 commits intomainfrom
Conversation
Overall package sizeSelf size: 1.99 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | source-map | 0.7.6 | 185.63 kB | 185.63 kB | | pprof-format | 2.2.1 | 163.06 kB | 163.06 kB | | node-gyp-build | 3.9.0 | 8.81 kB | 8.81 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
216d01f to
0d480d5
Compare
BenchmarksBenchmark execution time: 2026-03-05 10:33:13 Comparing candidate commit 3ed4376 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 91 metrics, 29 unstable metrics. |
9881a82 to
0e5f1dc
Compare
7ee93d7 to
b617efb
Compare
b617efb to
c4d4158
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a567e03d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
What does this PR do?:
Introduces a new
stopAndCollectfunction for the time profiler that reduces memory usage during profile serialization. Instead of materializing the entire V8 CPU profile tree as JS objects upfront, the new API resolves children on demand using getters.This also moves
totalHitCount()computation to C++ instead of TS to avoid getting children twice from C++Motivation:
The current
stop()API recursively translates the entire profile tree into JS objects, creating a full copy in heap memory which can be significant for large applications.The new
stopAndCollect()API uses a callback to keep the V8 profile alive while the TS serializer traverses the tree lazily.Scalar properties are set at creation time, but children are resolved on first access, reducing peak memory usage.
Additional Notes:
How to test the change?:
Unit tests