when I tried very_short then CPU utilization is same as 3.4.4 which has sbwt set to medium (default from erlang docs)
Hi Luke,
Thanks for your message.
I’ll take on board your comment about upgrading. I have been using the packages available in the Ubuntu 18.04 LTS repositories, but as you (and this link https://www.rabbitmq.com/install-debian.html) indicate, it does appear that there is a reasonable package-based alternative. Cheers.
If I understand the Erlang change logs correctly, “+sbwt none” in older versions of Erlang should do the same thing as “+sbwt none +sbwtdcpu none +sbwtdio none” in newer versions of Erlang. I think the change happened in Erts 10.0.
I imagine that my confusion just arises from not understanding Erlang internals well enough. Both https://www.rabbitmq.com/runtime.html#busy-waiting and http://erlang.org/doc/man/erl.html#+sbwt say that the option disables scheduler busy wait and that the schedulers go to sleep, and there is evidence that there are fewer syscalls (particularly sched_yield) being generated after switching to “+sbwt none”
However, strace shows that beam.smp is doing a spin lock which is busy waiting. Upon reflection, the documentation for +sbwt does seem to indicate it only applies to schedulers and not other aspects of the VM. It does seem like newer versions of Erlang use fewer spin locks, so maybe an upgrade will improve things too. I am OK if the answer is that the VM will always spin a bit and can’t be configured otherwise. I just want to know that it’s by design heh.
That said, I suppose I am a bit surprised that the VM spins so much. In the case of RabbitMQ, I can see where that would be handy in terms of performance for heavy workloads, but for light to moderate workloads it would be nice to just sleep and wake when there’s something to read over a network socket. I admit that I was digging through Golang internals yesterday to try to do a comparison, but I don’t know Erlang well enough to try a like-for-like comparison. Maybe that’s an exercise for me to do another time just for my own curiosity.
Anyway, it might be worth adding something to https://www.rabbitmq.com/runtime.html#busy-waiting saying that the Erlang VM will continue to busy wait overall and that this is normal and to be expected.
David Cook
Software Engineer
Prosentient Systems
72/330 Wattle St
Ultimo, NSW 2007
Australia
Office: 02 9212 0899
Online: 02 8005 0595
From: rabbitm...@googlegroups.com <rabbitm...@googlegroups.com> On Behalf Of Luke Bakken
Sent: Thursday, 8 October 2020 12:42 AM
To: rabbitmq-users <rabbitm...@googlegroups.com>
--
You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/BYJzgySEdr8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/1d718155-c03d-4ef9-8436-320e727d363co%40googlegroups.com.
Thanks for the well-worded message, M K. Much appreciated.
I did notice about 230 kernel threads being used by the 1 beam.smp process, so I figured that there must be something else going on too.
Your words inspire me. I’ve added “+sbwt none” and using strace, it looks like the frequent futex and clock_gettime syscalls are all coming from scheduler threads which are supposed to be asleep. While I see a few syscalls coming from threads with other names, it’s the scheduler threads (e.g. 1_scheduler through 8_scheduler) that seem to be spinning.
But, as Luke noted, this is an older RabbitMQ and Erlang. I am tempted to try a newer version and see how the Erlang VM behaves.
David Cook
Software Engineer
Prosentient Systems
72/330 Wattle St
Ultimo, NSW 2007
Australia
Office: 02 9212 0899
Online: 02 8005 0595
--
You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/BYJzgySEdr8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/ee5edc5b-42a9-4774-a5d3-b872f7813ee7o%40googlegroups.com.
Ok some updates…
I remembered that I have a openSUSE Leap 15.1 server running RabbitMQ 3.7.14 with Erlang 20.3.8.15 and Erts 9.3.3.6 with 12 CPU, and RabbitMQ is doing great there. It’s staying steady at 0% CPU usage when idle. Great! Every 10 seconds or so, it might spike to 0.333% or 2% or something. The majority of the work is being done by the “1_scheduler” thread and then a little bit on the “aux” thread. The other 11 scheduler threads are all sleeping like you’d hope/expect. There are lots of futex, clock_gettime, and epoll_pwait syscalls.
Using “docker run --rm -it -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="+sbwt none +sbwtdcpu none +sbwtdio none" rabbitmq:3.8.9”, the majority of work is being done by 1_scheduler thqread. It’s only a 2 CPU system and spikes to 2% every 5 seconds or so. 1_scheduler is pretty much just doing a spin lock with the futex syscall. The “aux” thread seems to be trying to polling a file descriptor pretty rapidly but I’m not bothered. Occasionally, 10_dirty_io_scheduler and 9_dirty_io_scheduler also do things ,which I find a bit surprising.
With Ubuntu 18.04 with RabbitMQ 3.6.10 with Erlang 20.2.2 and Erts 9.2, several scheduler threads are spinning. So I’m guessing there must be an Erlang optimization at some point between 20.2.2 and 20.3.8 where it only spins the 1st scheduler thread instead of all of them.
I reckon the Erlang (and consequently the RabbitMQ) documentation is a little bit misleading, as it’s clear that at least 1 scheduler, even on new RabbitMQ is still busy waiting, even when using +sbwt none (and friends).
Looks like openSUSE Leap 15.1 is using an older kernel than Ubuntu 18.04, so that’s probably not relevant. I’m curious why RabbitMQ seems to be working more efficiently when idling on openSUSE Leap 15.1 than Ubuntu 18.04.
Looking at the Dockerfiles, it looks like the Docker images use Ubuntu 18.04 as well (https://github.com/docker-library/rabbitmq/blob/35b41e318d9d9272126f681be74bcbfd9712d71b/3.8/ubuntu/Dockerfile).
I didn’t see anything obvious in terms of CLI command flags or environment variables that would explain the difference. Both the openSUSE Leap 15.1 and Ubuntu 18.04 have similar overall system load (and are both RabbitMQ instances are idling). But comparing a fully virtualized server and a Docker container isn’t really comparing apples to apples either.
Overall, it seems like upgrading RabbitMQ and Erlang would be a good idea, as it does seem like newer versions are more efficient. Even comparing the Ubuntu 18.04 fully virtualized server with the Docker container shows that the Docker container on the newer RabbitMQ/Erlang idles much more efficiently. A quick comparison suggests that the newer version idles using 3x less CPU time.
The older RabbitMQ on openSUSE used 2x less CPU time than the newer RabbitMQ in Docker…
Anyway, I suppose that’s my questions answered. I might get in touch with the Erlang team about clarifying their documentation.
David Cook
Software Engineer
Prosentient Systems
72/330 Wattle St
Ultimo, NSW 2007
Australia
Office: 02 9212 0899
Online: 02 8005 0595
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/030401d69d02%248f5201a0%24adf604e0%24%40prosentient.com.au.
Hi Gopi,
No, I just tried RabbitMQ 3.8.9. I’m not sure which Erlang it used although I could take a look.
I just tried “docker run --rm -it -e RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="+sbwt none +sbwtdcpu none +sbwtdio none" rabbitmq:3.8.5”, and it looks like it’s using Erlang/OTP 23 and Erts 11.0.3. Seemed to run the same as the 3.8.9.
David Cook
Software Engineer
Prosentient Systems
72/330 Wattle St
Ultimo, NSW 2007
Australia
Office: 02 9212 0899
Online: 02 8005 0595
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/c3f7f5b0-4a7c-4b6d-b0db-49be09df4145n%40googlegroups.com.
Cheers, Gerhard. The details you’ve added in erlang-questions are really interesting.
What function is used to collect those metrics every 5 seconds? Is the interval controlled by the “collect_statistics_interval” key?
I’m tempted to play with that configuration now to see if that is what is responsible for most of the CPU usage I was seeing…
David Cook
Software Engineer
Prosentient Systems
72/330 Wattle St
Ultimo, NSW 2007
Australia
Office: 02 9212 0899
Online: 02 8005 0595
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/055acb19-eb19-4fc4-9010-4752ca6f9029n%40googlegroups.com.