unikraft / app-redis

Redis on Unikraft
5 stars 12 forks source link

Redis on Unikraft uses 100% of the CPU available #12

Closed andrejvelichkovski closed 1 year ago

andrejvelichkovski commented 1 year ago

Hello,

While testing Unikraft with Redis, I noticed that it uses 100% of the available CPU core/thread. This is easily noticeable when launching 4 Unikraft Redis instances (I have 2-core/4-Threads machine). When running top we can see that the qemu processes all use almost 100% of the available resources (picture below).

redis-cpu-usage

I'm running the 0.10.0 version of Unikraft.

marcrittinghaus commented 1 year ago

Hi @andrejvelichkovski,

this is a known issue which is caused by a cancellable wait in lib-pthread-embedded (https://github.com/unikraft/lib-pthread-embedded/blob/e2705f98bcb17f423547c2394cc672a52de3d1e4/pte_osal.c#L556), which is currently implemented with a busy loop.

Since we moved from newlib + pthread-embedded to musl since the 0.11 release last week and using newlib+pthread-embedded has been deprecated this is likely not being fixed very soon.

For a quick fix, you can avoid the busy loop by replacing the offending code with a simple timed wait on the semaphore. Of course, this will disable the cancellation feature.

andrejvelichkovski commented 1 year ago

Thanks for the quick answer @marcrittinghaus. I will switch to the newer version of unikraft.