<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="124640" data-post-id="124640">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ellispritchard" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ellispritchard/120/13985_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ellispritchard
                      <span class="op-star" title="Thread Starter">
                        <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                      </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="seb5law" data-post="21" data-topic="21493">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/s/e47c2d/48.png" class="avatar"> seb5law:</div>
<blockquote>
<p>As I understand the documentation the <code>sbwt*</code> flags should be set to longer in order to keep idle schedulers alive for longer so new work will be accepted faster without the need of starting a new scheduler.</p>
</blockquote>
</aside>
<p>So this is the flag I have been thinking might have been causing me trouble, <em>when running under CFS quotas with other processes</em>.</p>
<p>For reference, see this design doc for the CFS: <a href="https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt" rel="noopener nofollow ugc">https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt</a></p>
<p>TL;DR:</p>
<blockquote>
<p>CFS’s task picking logic is very simple: it always tries to run the task with the smallest runtime value (i.e., the task which executed least so far). CFS always tries to split up CPU time between runnable tasks as close to “ideal multitasking hardware” as possible.</p>
</blockquote>
<p>The theory is that the Erlang scheduler busy-looping is causing the CFS to record more CPU usage against the Erlang scheduler threads than they are using to do useful work in my code, and thus the Erlang scheduler thread gets throttled, to be fair to other threads e.g. if the quota is 100us of work, and if I do 50us of work in my code, before needing to wait on a socket, and there’s no other work for the Erlang scheduler to do, the busy-looping kicks in, and burns the remaining 50us for possibly no benefit, and thus the CFS thinks I’ve used my entire allocation, and throttles me, instead of allowing me to do more work shortly after…</p>
<p>So in my case, running Erlang in Docker, assuming the theory is correct, I would want to set <code>+sbwt</code> to <code>none</code> or <code>very_short</code> to avoid being throttled by the CFS, assuming that being throttled is worse than not <em>immediately</em> reacting to an event that might allow the Erlang scheduler to run my process.</p>
<p>If you are not being constrained in your use of CPU by a kernel scheduler, but trying to out-compete other processes on the same box, you won’t have the same rationalisation.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="124640" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/performance-of-erlang-elixir-in-docker-kubernetes/21493/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-124640" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="124640"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #22"></div>
  </section>
</div>
    <div class="postbit" id="124644" data-post-id="124644">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ellispritchard" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ellispritchard/120/13985_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ellispritchard
                      <span class="op-star" title="Thread Starter">
                        <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                      </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here’s another performance snag that might effect at least some of us; not specific to Erlang, but to those on older AWS instance types:</p>
<p><a href="https://news.ycombinator.com/item?id=13813079" rel="noopener nofollow ugc">Two frequently used system calls are ~77% slower on AWS EC2</a></p>
<p>and also, with particular reference to Docker (scroll to the end past all the Java stuff):</p>
<p><a href="https://medium.com/appian-engineering/yet-another-reason-your-docker-containers-may-be-slow-on-ec2-clock-gettime-gettimeofday-and-9d92f6892048" rel="noopener nofollow ugc">Yet another reason your Docker containers may be slow on EC2: clock_gettime, gettimeofday and seccomp</a></p>
<p>TL;DR<br>
<strong>this call [<code>gettimeofday</code>] in Docker can take almost 6 times as long as a non-containerized call due to the overhead of seccomp filters running on the system call</strong></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="124644" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/performance-of-erlang-elixir-in-docker-kubernetes/21493/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-124644" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="124644"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #23"></div>
  </section>
</div>
    <div class="postbit" id="262971" data-post-id="262971">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mattbaker" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mattbaker/120/3698_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mattbaker
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>If anyone (like myself) stumbles across this old thread I want to say that +sbwt none made a significant impact on our CPU usage (as CFS measures it). We’re seeing a 50% drop. If you’re running in an environment where CFS is in play you should experiment with this!</p>
<p><a class="mention" href="/u/ellispritchard" rel="nofollow">@ellispritchard</a> your explanation makes a lot of sense and I think you’re correct. Just here to +1 and encourage others to try this flag, I really appreciated this thread and your findings. Thanks <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="262971" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/performance-of-erlang-elixir-in-docker-kubernetes/21493/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-262971" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="262971"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #24"></div>
  </section>
</div>
    <div class="postbit" id="263037" data-post-id="263037">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ellispritchard" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ellispritchard/120/13985_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ellispritchard
                      <span class="op-star" title="Thread Starter">
                        <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                      </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thanks <a class="mention" href="/u/mattbaker" rel="nofollow">@mattbaker</a> glad to find it’s still relevant (and helpful!)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="263037" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/performance-of-erlang-elixir-in-docker-kubernetes/21493/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-263037" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="263037"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>