You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Large virtual memory (13-20 GB) when running Peertube without --jitless #45557
nodejs will grow up to 13 GB - 20 GB memory (depending on node version/OS)
How often does it reproduce? Is there a required condition?
Same behaviour at every run. Seems easy to reproduce.
What is the expected behavior?
13-20 GB seems to be a lot more than necessary.
Starting with --jitless seems to shrink the memory size significantly to ~1 GB, which looks more reasonable:
Perhaps there's a specific Javascript module with specific code which triggers excessive memory use in the JIT compiler, but I have no idea how to check for this.
What do you see instead?
nodejs grows up to 13 GB - 20 GB memory (depending on node version/OS -- same observations on node14/FreeBSD, Linux, and on other Peertube instances)
Additional information
Posted here on the Peertube forum, where I was advised to come here and ask for help.
@pbeyssac Could you provide the output of cat /proc/74144/status please, replacing 74144 with the actual PID of the node process when its memory usage appears to be high?
@pbeyssac Could you provide the output of cat /proc/74144/status please, replacing 74144 with the actual PID of the node process when its memory usage appears to be high?
Note that it is FreeBSD's /proc, which is different from the Linux output, so here's the relevant bit in the man page:
status The process status. This file is read-only and returns a single
line containing multiple space-separated fields as follows:
• command name
• process id
• parent process id
• process group id
• session id
• device name of the controlling terminal, or a minus sign
(“-”) if there is no controlling terminal.
• a list of process flags: ctty if there is a controlling
terminal, sldr if the process is a session leader, noflags if
neither of the other two flags are set.
• the process start time in seconds and microseconds, comma
separated.
• the user time in seconds and microseconds, comma separated.
• the system time in seconds and microseconds, comma separated.
• the wait channel message
• the process credentials consisting of the effective user id
and the list of groups (whose first member is the effective
group id) all comma separated.
• the hostname of the jail in which the process runs, or ‘-’ to
indicate that the process is not running within a jail.
Please find attached the memory map of the process as returned by /proc/${pid}/map. map.txt
Another remark (I'm not sure this is relevant, but just in case): the process I started with --jitless died on an error which looks like a Peertube error, but which never happens when running with JIT. Perhaps a race condition due to the code running at a different speed.
[...:443] 2022-11-21 12:06:17.761 error: uncaughtException: Cannot read properties of undefined (reading 'timeoutType')
TypeError: Cannot read properties of undefined (reading 'timeoutType')
at _resume (/var/www/peertube/versions/peertube-v4.3.1/node_modules/undici/lib/client.js:1167:29)
at resume (/var/www/peertube/versions/peertube-v4.3.1/node_modules/undici/lib/client.js:1131:3)
at connect (/var/www/peertube/versions/peertube-v4.3.1/node_modules/undici/lib/client.js:1116:3) {
"error": {
"stack": "TypeError: Cannot read properties of undefined (reading 'timeoutType')\n at _resume (/var/www/peertube/versions/peertube-v4.3.1/node_modules/undici/lib/client.js:1167:29)\n at resume (/var/www/peertube/versions/peertube-v4.3.1/node_modules/undici/lib/client.js:1131:3)\n at connect (/var/www/peertube/versions/peertube-v4.3.1/node_modules/undici/lib/client.js:1116:3)",
"message": "Cannot read properties of undefined (reading 'timeoutType')"
},
(...)
This looks like /stat, not /status. /stat does not contain the accumulated memory info.
I confirm it is really /proc/${pid}/status on FreeBSD (see the "cat", directly copied from my terminal). FreeBSD /proc differs from Linux and has no /proc/*/stat anyway.
Here /rlimit just in case (but these are static limits, not usage):
rlimit This is a read-only file containing the process current and
maximum limits. Each line is of the format rlimit current max,
with -1 indicating infinity.
Excerpt from ps:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
peertube 94670 0,0 0,3 13254356 203024 5 S+J 12:19 0:12,45 node: peertube (node)
Sorry, I was looking at the man page for CentOS, not FreeBSD.
The RSS looks reasonable. Maybe the JIT compiler creates a bunch of large memory mappings thus blowing up the reserved address space in virtual memory, but that's usually not a problem. (For example, V8 might decide to reserve a 4GiB address range for every single WebAssembly instance for performance reasons.)
Maybe the JIT compiler creates a bunch of large memory mappings
That's what happens. I'm going to guess peertube loads wasm files (undici does, of that I'm sure) and V8 makes large reservations for wasm modules, basically XL guard pages. That's virtual memory though, not RSS, so it's harmless.
changed the title [-]Extremely high node18/node14 memory use (13-20 GB) when running Peertube, fixed by running with --jitless[/-][+]Large virtual memory (13-20 GB) when running Peertube without --jitless[/+]on Nov 22, 2022
Activity
tniessen commentedon Nov 21, 2022
@pbeyssac Could you provide the output of
cat /proc/74144/statusplease, replacing74144with the actual PID of thenodeprocess when its memory usage appears to be high?pbeyssac commentedon Nov 21, 2022
Thanks for your reply.
Here goes:
Note that it is FreeBSD's /proc, which is different from the Linux output, so here's the relevant bit in the man page:
Please find attached the memory map of the process as returned by /proc/${pid}/map.
map.txt
Another remark (I'm not sure this is relevant, but just in case): the process I started with --jitless died on an error which looks like a Peertube error, but which never happens when running with JIT. Perhaps a race condition due to the code running at a different speed.
tniessen commentedon Nov 21, 2022
This looks like
/stat, not/status./statdoes not contain the accumulated memory info.pbeyssac commentedon Nov 21, 2022
I confirm it is really /proc/${pid}/status on FreeBSD (see the "cat", directly copied from my terminal). FreeBSD /proc differs from Linux and has no /proc/*/stat anyway.
Here /rlimit just in case (but these are static limits, not usage):
man page excerpt:
Excerpt from ps:
tniessen commentedon Nov 21, 2022
Sorry, I was looking at the man page for CentOS, not FreeBSD.
The RSS looks reasonable. Maybe the JIT compiler creates a bunch of large memory mappings thus blowing up the reserved address space in virtual memory, but that's usually not a problem. (For example, V8 might decide to reserve a 4GiB address range for every single WebAssembly instance for performance reasons.)
bnoordhuis commentedon Nov 22, 2022
That's what happens. I'm going to guess peertube loads wasm files (undici does, of that I'm sure) and V8 makes large reservations for wasm modules, basically XL guard pages. That's virtual memory though, not RSS, so it's harmless.
[-]Extremely high node18/node14 memory use (13-20 GB) when running Peertube, fixed by running with --jitless[/-][+]Large virtual memory (13-20 GB) when running Peertube without --jitless[/+]