-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
worker: add worker.getHeapStatistics() #57888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
worker: add worker.getHeapStatistics() #57888
Conversation
In Lines 57 to 71 in 2204587
|
daafec6
to
85d6960
Compare
Adds worker.getHeapStatistics() so that the heap usage of the worker could be observer from the parent thread. Signed-off-by: Matteo Collina <hello@matteocollina.com>
c10f5e8
to
c73d1b6
Compare
src/node_worker.cc
Outdated
|
||
v8::HeapStatistics heap_stats; | ||
w->isolate_->GetHeapStatistics(&heap_stats); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use the object constructor that takes an array of keys and array of values, it will be faster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you got an example I can copy from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Src/node_v8.cc line 350
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only thing that might be of concern would be that placing this on the worker object loses the isolation as v8-specific that the one in the v8 module has. An alternative implementation could be something like v8.getWorkerHeapStatistics(worker) to keep it in that v8-specific segment of the API, if that's something we care about. I would not block on this, but I figured it worth bringing up.
Other than that, agreed that the array form object construction would be better.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57888 +/- ##
==========================================
- Coverage 90.24% 90.23% -0.01%
==========================================
Files 630 630
Lines 185688 185783 +95
Branches 36403 36414 +11
==========================================
+ Hits 167569 167647 +78
- Misses 10997 11009 +12
- Partials 7122 7127 +5
🚀 New features to boost your workflow:
|
There is a precedent of |
There is also the event loop utilization monitoring that can be done from the outside, too. |
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@joyeecheung @legendecas PTAL. |
Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@Qard @RaisinTen PTAL |
Sorry, I need another LGTM due to an unexpected test failure on ARM. |
Landed in 33d8e03 |
Adds
worker.getHeapStatistics()
so that the heap usage of the worker could be observer from the parent thread.