diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2020-04-11 03:56:12 +0300 |
---|---|---|
committer | avih <avih@users.noreply.github.com> | 2020-11-15 20:36:04 +0200 |
commit | 932c1ada0f9b0f7078c09ef0179119c838eef84a (patch) | |
tree | 3628d293f6b3f449dd5e5b3898955f147addc112 /DOCS | |
parent | cc25137eaec92bcbe6c20632c644bfa9a2369a6a (diff) | |
download | mpv-932c1ada0f9b0f7078c09ef0179119c838eef84a.tar.bz2 mpv-932c1ada0f9b0f7078c09ef0179119c838eef84a.tar.xz |
js: report scripts CPU/memory usage statistics
This can be viewed at page 4 of the internal stats display (i or I).
CPU time report is the same as at lua.c, but untested - doesn't seem
to work on windows - also not for lua.
TL;DR: Set env MPV_LEAK_REPORT=1 to enable js memory reporting stats.
This also almost doubles the memory usage by js scripts.
For memory reporting, we don't have enough info by default, because
even when using a custom allocator, mujs doesn't report the old size
(on free or realloc) because it doesn't track this value, and as
a result we can't track the overall size.
Our option are either to track the size of each allocation on our own,
or use talloc which tracks this value.
However, using talloc for mujs allocations adds a considerable
overhead, and almost doubles(!) the overall memory used, because each
individual allocation includes a considerable talloc header, and mujs
does many small allocations.
So our solution is that by default we behave like previously - not
using a custom allocator with mujs, and stats does not display memory
usage for js scripts.
However, if the env var MPV_LEAK_REPORT is set to 1, then we use
a custom allocator with talloc and track/report memory usage.
We can't switch allocator at runtime, so an mpv instance either tracks
or doesn't track js scripts memory usage, according to the env var.
(we could use a property and apply it whenever a new script starts,
so that it could change for newly launched scripts, but we don't).
Diffstat (limited to 'DOCS')
-rw-r--r-- | DOCS/man/stats.rst | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/DOCS/man/stats.rst b/DOCS/man/stats.rst index 4f9496f4de..2cf730f673 100644 --- a/DOCS/man/stats.rst +++ b/DOCS/man/stats.rst @@ -212,6 +212,10 @@ are missing. Memory usage is approximate and does not reflect internal fragmentation. +JS scripts memory reporting is disabled by default because collecting the data +at the JS side has an overhead. It can be enabled by exporting the env var +``MPV_LEAK_REPORT=1`` before starting mpv, and will increase JS memory usage. + If entries have ``/time`` and ``/cpu`` variants, the former gives the real time (monotonic clock), while the latter the thread CPU time (only if the corresponding pthread API works and is supported). |