Skip to content
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

Support clean shutdown to allow usage under Native Image Isolates #6702

Open
davidfrickert opened this issue Jun 11, 2021 · 0 comments
Open
Labels
enhancement Feature not a bug
Milestone

Comments

@davidfrickert
Copy link

As exposed on the issue #6173 comments, currently, OkHttp's daemon threads (Watchdog & TaskRunner) won't exit when getting interrupted, they stay alive until the keepalive has been exceeded, which seems to be 60s.

In traditional applications, this doesn't seem to be a problem, but in Native Image Isolates it is.

On a GraalVM Native Image Isolate situation, the expected workflow is to allow code to execute isolated, and these Isolates can be created and destroyed at will. They are essentialy, a small disjoint heap that is cheap to create and destroy quickly.

The pre-requisite to destroying them is that no Threads must be currently executing, so, the logic is that before destroying an Isolate, each thread that is currently running withing such Isolate is interrupted, and then wait until all threads have exited.
If threads don't exit, the Thread currently managing the destruction of such isolate will stay stuck until such threads exit, and of course, the isolate will continue using memory that could be freed.
This is the case of OkHttp, since the interrupt doesn't seem to do anything, the thread just waits for 60s and then when the OkHttp daemon threads exit, it proceeds to destroy the isolate.

Opening this issue to ask if this can be done, and to generate some discussion about the possible solutions and their implications.

Blog post about Isolates
https://medium.com/graalvm/isolates-and-compressed-references-more-flexible-and-efficient-memory-management-for-graalvm-a044cc50b67e

Some documentation on the Isolate API
https://www.graalvm.org/reference-manual/native-image/C-API/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature not a bug
Projects
None yet
Development

No branches or pull requests

2 participants