Scheduler threads high CPU utilization on Erlang 11.0.3

Lukas Larsson lukas@REDACTED
Mon Oct 12 10:45:34 CEST 2020


"other" does not have to be to busy wait. It could be other things as well.
If you want to know, you can run using an emulator with extra msacc states
as described here:
Having said that, it does sound like it is busy wait that is consuming the
extra CPU in your case, but it would be good to confirm that it is so.

You could also run linux perf (if you are on linux) to see what the
emulator is spending time on.

On Fri, Oct 9, 2020 at 11:12 PM Gopi V <gopi1828@REDACTED> wrote:

> Note: Reposting this as I haven't got any response.
> I've upgraded from rabbitMQ version: 3.4.4 on Erlang R16B03 (erts-5.10.4)
> to rabbitMQ 3.8.5 on Erlang 11.0.3 (OTP 23).
> When I ran rabbitmq-perf-test on 3.8.5 it was able to handle 1000's of
> messages per second with 500 producers and 500 consumers. (
> I did
> see CPU utilization around 500%-600% on 8 CPU system whereas it stayed
> below 1 CPU utilization for 100-200 messages/sec which is the case of 3.4.4
> production cluster.
> But in production 3.8.5 is taking 50% more CPU when compared to 3.4.4.
> Below is the output of rabbitmq-diagnostics runtime_thread_stats which is
> taking more time on other (I assume its busy wait). The default value of
> scheduler busy wait (sbwt) is medium on both the version of erlang. When I
> changed this to None the CPU utilization went down from 4-5 CPU's to 1 CPU,
> when I tried very_short then CPU utilization is same as 3.4.4 which has
> sbwt set to medium (default from erlang docs). Is this a know issue?
> Average thread real-time : 5000228 us
> Accumulated system run-time : 12160527 us
> Average scheduler run-time : 1511950 us
>     Thread      aux check_io emulator       gc    other     port    sleep
> Stats per thread:
> scheduler( 1) 0.47% 0.52% 7.89% 0.54% 52.64% 1.27% 36.68%
> scheduler( 2) 0.53% 0.49% 7.15% 0.52% 51.70% 1.11% 38.51%
> scheduler( 3) 0.50% 0.50% 7.46% 0.51% 52.58% 1.17% 37.28%
> scheduler( 4) 0.40% 0.35% 5.33% 0.36% 46.75% 0.79% 46.01%
> (ignoring scheduler 5 to 8)
> Setting below value will for sure reduce CPU utilization.
> RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="+sbwt very_short +sbwtdcpu very_short
> +sbwtdio very_short"
> or
> RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="+sbwt none +sbwtdcpu none +sbwtdio
> none"
> But I want to know
> erts-5.10.4 has only *sbwt flag with *default value as medium (
> Erlang 11.0.3 has *sbwt flag with *default value as medium (
> but also introduced *sbwtdcpu and **sbwtdio* with default value as short.
> From settings nothing has changed with scheduler busy wait threshold and I
> do see twice CPU utilization with 11.0.3.
> 1. Does anyone know there are significant amount of change in scheduling
> that would cause this?

Since R16 a lot has happened in the emulator, so I'm not surprised that you
are seeing different behavior. The largest change is the addition of dirty
schedulers, but there are also numerous other small changes. You can have a
look at the changelog for more details:

> 2. If yes, then apart from consuming CPU when traffic is sparse does this
> have any negative impact when traffic is continuous and number of messages
> doubles? Technically,  in this scenario scheduler threads won't be in busy
> wait state.

I'm not 100% sure I understand what you mean. Busy wait is the action of
spinning while waiting for new events to become active. It is done because
it is relatively expensive to go a sleep rather than spinning. If you are
unlucky, the schedulers in your system will always be woken up just as they
go to sleep, which would be very bad for CPU utilization.

> 3. I tried to replicate my production scianrio with 500 messages/secs for
> 10 secs and keeping it idle for 3 secs but rabbitMQ is only utilizing 1 CPU
> and less 10% on of busy wait. I want to replicate a scenario where for a
> workload 3.8.5 has 50% on busy wait consuming x CPU's while 3.4.4 consumes
> x/2 CPU's. Then go back to 3.8.5 and set *sbwt to very_short *and run the
> test again to see if there was any significant impact on throughput.

The default busy-wait time is much shorter than 3 seconds, maybe a couple
of milliseconds at most, but normally under that. I don't know how to
trigger it using PerfTest.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the erlang-questions mailing list