-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Workers affected by V8 aborting on virtual allocation failure #25933
Comments
It's come up on the v8-users mailing list more than once and I believe there are multiple V8 developers on record saying graceful handling of OOM errors is an explicit non-goal. But cc @nodejs/v8 just in case. :) |
there is a way to hook into OOM |
The OOM hook works when the OOM happens due to heap object allocations. In this case we are exhausting the virtual memory on isolate initialization. The reason is that on 64-bit platforms, an isolate pre-allocates 128MB virtual range for code objects. The workaround would be to reduces the code range size for workers using ResourceConstraints::set_code_range_size[1] We could also move the code range construction to the beginning of the isolate initialization and return some indication of error, so that the embedder can handle that gracefully. |
I'm aware of Put another way, there's room to improve the status quo but no complete fix is possible. Is that a correct summary? |
@bnoordhuis that's right |
@ulan Returning with an error if the Is there a way to get around the @bnoordhuis Now that |
@trevnorris limiting the resident set size with |
@hashseed do you know if the spec allows throwing an error in |
We don't necessarily follow the spec in regards to all specifics around the workers api, fwiw. |
@ulan Looking through the Web Workers spec, this is the most relevant thing I can find:
I interpret that as it being node's job to make sure the application doesn't crash on OOM. Though, because running the Worker should be done in parallel the OOM error would need to be passed to In short, the spec doesn't specify how OOM should be handled, but does does seem to give "user agents" control over how they should be handled (though my spec interpretation skills are average at best, and need confirmation by someone else). Note: |
@ulan Yeah, I think that would be best… |
worker_threads
A process aborts when V8 fails to allocate virtual memory. This is detremental to using
Workers
because:Worker
fails to allocate virtual memory during initialization the process aborts.ulimit
.To demonstrate this issue:
ulimit -v
to some value smaller than actual physically available memory (I've allocated 8GB out of 16GB).Worker
s (the number to spawn may need adjusting depending on the system):Which results in a
Fatal process OOM in CodeRange setup: allocate virtual memory
error. With the stack trace of:Examination of the
strace
log shows:Though if I run the same script on a machine with 8GB physical memory and
ulimit -v unlimited
the script doesn't have a problem.In the end, this is probably something that'd need to be resolved by V8. Both to allocate virtual memory more intelligently and allow the
Isolate
to notify when no more memory could be allocated. Then have that hooked into theWorker
's'error'
event.The text was updated successfully, but these errors were encountered: