In libuv, you can end up tying up the worker threads with too much work or buggy code. Is there a simple function that can check the health of the worker threads or thread queue? It doesn't have to be 100% deterministic, after all it would be impossible to determine whether the worker thread is hanging on slow code or an infinite loop.
So any of the following heuristics would be good:
Number of queued items not yet worked on. If this is too large, it could mean the worker threads are busy or hung.
Does libuv have any thread killing mechanism where if the worker thread doesn't check back in n seconds, it gets terminated?
That function does not exist in libuv itself, and I am not aware of any OSS that provides something like that.
In terms of a killing mechanism, there is none baked into libuv, but http://nikhilm.github.io/uvbook/threads.html#core-thread-operations suggests:
A well designed program would have a way to terminate long running workers that have already started executing. Such a worker could periodically check for a variable that only the main process sets to signal termination.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With