-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
worker: add worker.getMemoryUsage() API #60778
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #60778 +/- ##
==========================================
- Coverage 88.57% 88.54% -0.04%
==========================================
Files 703 703
Lines 208256 208347 +91
Branches 40158 40174 +16
==========================================
+ Hits 184469 184486 +17
- Misses 15824 15851 +27
- Partials 7963 8010 +47
🚀 New features to boost your workflow:
|
| Number::New(isolate, heap_stats.external_memory()), | ||
| Number::New(isolate, allocator == nullptr | ||
| ? 0 | ||
| : allocator->total_mem_usage()), |
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.
There's no guarantee that allocator is still alive at this point
| <!-- YAML | ||
| added: | ||
| changes: | ||
| - version: v25.2.0 |
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.
| - version: v25.2.0 | |
| - version: REPLACEME |
| `SharedArrayBuffer` instances within the worker. | ||
| The returned `Promise` rejects with [`ERR_WORKER_NOT_RUNNING`][] if called after | ||
| the worker has stopped. |
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.
This should explain the relationship to worker.getHeapStatistics() and how it differs from that
| Returns an object mirroring [`process.memoryUsage()`][] but scoped to the | ||
| worker's isolate: | ||
| * `rss` {integer} Resident Set Size. This value represents the RSS reported by |
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.
Isn't RSS a per process thing?
Therefore RSS value should be the same on all workers so quite pointless to read it from a different thread.
| added: | ||
| changes: | ||
| - version: v25.2.0 | ||
| pr-url: https://github.com/nodejs/node/pull/REPLACEME |
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.
| pr-url: https://github.com/nodejs/node/pull/REPLACEME | |
| pr-url: https://github.com/nodejs/node/pull/60778 |
Summary
worker.getMemoryUsage()so worker threads can report RSS, heap usage, external memory, and ArrayBuffer statistics.WorkerMemoryUsageTakerplus the per-isolate templates/bindings to expose this data.test/parallel/test-worker-get-memory-usage.js) and document the API indoc/api/worker_threads.md.Testing
python3 tools/test.py parallel/test-worker-get-memory-usageninja -C out/Debug node