<div dir="ltr"><div>Hello,</div><div><br></div><div>"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: <a href="http://erlang.org/doc/man/erlang.html#statistics_microstate_accounting">http://erlang.org/doc/man/erlang.html#statistics_microstate_accounting</a>. 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.<br></div><div><br></div><div>You could also run linux perf (if you are on linux) to see what the emulator is spending time on.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 9, 2020 at 11:12 PM Gopi V <<a href="mailto:gopi1828@gmail.com">gopi1828@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Note: Reposting this as I haven't got any response. <br clear="all"><div><br></div><div><div><div>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).</div><div>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. (<a href="https://rabbitmq.github.io/rabbitmq-perf-test/stable/htmlsingle" rel="nofollow" style="color:rgb(26,115,232);text-decoration-line:none" target="_blank">https://rabbitmq.github.io/rabbitmq-perf-test/stable/htmlsingle</a>). 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.</div><div>But in production 3.8.5 is taking 50% more CPU when compared to 3.4.4.</div><div><br></div><div>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?</div><div><br></div><div>Average thread real-time : 5000228 us</div><div>Accumulated system run-time : 12160527 us</div><div>Average scheduler run-time : 1511950 us</div><div><br></div><div>    Thread      aux check_io emulator       gc    other     port    sleep</div><div>Stats per thread:</div><div>scheduler( 1) 0.47% 0.52% 7.89% 0.54% 52.64% 1.27% 36.68%</div><div>scheduler( 2) 0.53% 0.49% 7.15% 0.52% 51.70% 1.11% 38.51%</div><div>scheduler( 3) 0.50% 0.50% 7.46% 0.51% 52.58% 1.17% 37.28%</div><div>scheduler( 4) 0.40% 0.35% 5.33% 0.36% 46.75% 0.79% 46.01%</div><div>(ignoring scheduler 5 to 8)</div></div><div><br style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px"></div><div><br></div><div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">Setting below value will for sure reduce CPU utilization.</div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px"><br></div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="+sbwt very_short +sbwtdcpu very_short +sbwtdio very_short"<br><br></div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">or </div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px"><br></div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="+sbwt none +sbwtdcpu none +sbwtdio none" <br></div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px"><br></div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">But I want to know </div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">erts-5.10.4 has only <strong>sbwt flag with </strong>default value as medium (<a href="http://erlang.org/documentation/doc-5.10.4/erts-5.10.4/doc/html/erl.html" rel="nofollow" style="color:rgb(26,115,232);text-decoration-line:none" target="_blank">http://erlang.org/documentation/doc-5.10.4/erts-5.10.4/doc/html/erl.html</a>). Erlang 11.0.3 has <strong>sbwt flag with </strong>default value as medium (<a href="http://erlang.org/documentation/doc-11.0-rc3/erts-11.0/doc/html/erl.html#+sbt" rel="nofollow" style="color:rgb(26,115,232);text-decoration-line:none" target="_blank">http://erlang.org/documentation/doc-11.0-rc3/erts-11.0/doc/html/erl.html#+sbt</a>) but also introduced <strong>sbwtdcpu and </strong><strong>sbwtdio</strong> 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. </div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">1. Does anyone know there are significant amount of change in scheduling that would cause this? <br></div></div></div></div></blockquote><div><br></div><div>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:  <a href="http://erlang.org/doc/apps/erts/notes.html">http://erlang.org/doc/apps/erts/notes.html</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px"></div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">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.</div></div></div></div></blockquote><div><br></div><div>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.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div style="color:rgba(0,0,0,0.87);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">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 <strong>sbwt to very_short </strong>and run the test again to see if there was any significant impact on throughput. </div></div></div></div></blockquote><div><br></div><div>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.</div><div><br></div><div>Lukas</div></div></div>