| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I struggle to see how this API can ever stabilize - what one can do when the heap is near the heap limit is very limited, and in particular if you do too much in the callback to incur another allocation, the program would be in a very unstable state. Our current callbacks only do very limited things within the C++, allowing users to do arbitrary things in JS sounds like an API that invites bugs...I think a safer option would be to only write a profile when it reaches the limit, though even then I am not sure how well the profiler works when the heap is about to reach the limit... |
Sorry, something went wrong.
|
I'm also wary on adding a JS callback to be invoked at new heap limit. This callback also takes a heap profile parameter which is taken on a big heap, sounds like exacerbating the problem it wants to fix. |
Sorry, something went wrong.
|
|
||
| v8.startHeapProfile(); | ||
| v8.setHeapProfileNearHeapLimit((profile) => { | ||
| console.log(JSON.parse(profile)); |
There was a problem hiding this comment.
This example asks users to exacerbating the heap usages when the heap is near limit...
Sorry, something went wrong.
|
This API is not intended to make JS safe near OOM. It closes a blind spot in the sampling heap profiler: today, if a process starts startHeapProfile() and reaches a fatal OOM, the accumulated sampling data is lost because stopHeapProfile() is never called so the API provides a best-effort chance to retrieve that data before the process terminates. |
Sorry, something went wrong.
|
Why would the application want to save the profile in JS memory when it's likely not relevent for the application itself that may already crash soon? I think a file-backed API would achieve the same thing without making the users waste the remaining memory with (arguably very noisy) diagnostic data. |
Sorry, something went wrong.
|
@joyeecheung Yes I agree with your proposal! I changed the approach to a file-backed one. please feel free to review it |
Sorry, something went wrong.
Codecov Report❌ Patch coverage is 49.24242% with 67 lines in your changes missing coverage. Please review.
@@ Coverage Diff @@
## main #64676 +/- ##
==========================================
- Coverage 90.12% 90.12% -0.01%
==========================================
Files 751 751
Lines 253629 253767 +138
Branches 47789 47808 +19
==========================================
+ Hits 228575 228697 +122
- Misses 16305 16312 +7
- Partials 8749 8758 +9
... and 34 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was a problem hiding this comment.
If I understand the motivation correctly, the intent is to write out the samples from a long-running heap profiler before the process dies of OOM, rather than losing them.
limit makes sense for setHeapSnapshotNearHeapLimit(). A snapshot is a point-in-time object graph, so each capture is a genuinely new state, N of them are diff-able, and Chrome DevTools supports comparing them out of the box.
The sampling profiler is different. It maintains a running live-set keyed by allocation site, so for diagnostic purposes, profile N+1 answers everything profile N does, which makes every file but the last redundant.
I wonder if the API can be simplified as a single final dump for the heap profiler?
Sorry, something went wrong.
|
@legendecas The sampler's live set isn't monotonic, so profile N+1 isn't a superset of profile N (with the default flags kSamplingNoFlags) a major GC always runs between two near-heap-limit callbacks, since those are the last-resort GC paths. So each profile drops whatever died since the previous one, which is often the spike that triggered it. limit here is a budget on how many times we do expensive allocating work on a near-OOM path. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for clarifying. Would you mind applying the same permission check added on #64808? Thanks
Sorry, something went wrong.
Sorry, something went wrong.
|
Would you mind rebasing the commits and squash them? CI is not really good at handling merge commits. |
Sorry, something went wrong.
Signed-off-by: ishabi <ilyasshabi94@gmail.com>
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR adds the v8.setHeapProfileNearHeapLimit(limit) API, which writes the active sampling heap profile to disk when V8 approaches the heap limit. It complements v8.setHeapSnapshotNearHeapLimit() use cases that need a sampled allocation profile rather than a full heap snapshot.
Heap profiling must first be enabled using v8.startHeapProfile() or the --heap-prof CLI option.
v8.setHeapProfileNearHeapLimit() and v8.setHeapSnapshotNearHeapLimit() can be active on the same isolate.