[Libwebsockets] libwebsocket message loop thread take 100% of the CPU
andy at warmcat.com
Tue Aug 25 07:33:01 CEST 2020
On 8/24/20 4:58 PM, Nagendra Kumar Goel (नगेन्द्र गोयल) wrote:
> What I have specifically seen is that we have a number of worker threads
> that handle incoming web requests (on the LWS based server) and the main
> thread has the message processing. The main thread would normally
> consume 0-1% CPU. However very occasionally (let's say after 10 days of
> uptime) It would start consuming 100% CPU. Then we have to restart the
> program to get it back to 0% CPU usage. I have not yet identified the
> source of this problem. Interestingly only one binary displays this
> behavior, and attaching a gdb to the process and pausing it takes me to
> a join() statement.
Like pthread_join()? Lws only has one of those in threadpool, which is
off by default. If you have other threads active, you'll need to switch
the gdb thread context to the other threads (info threads, t 2 or
whatever) and see what they are doing. pthread_join() is just one
thread waiting for another to exit, it does not spin.
On Linux you can also come at spinning with perf top, to get a breakdown
of where the code is spending its time.
More information about the Libwebsockets