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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Is your repository now adjusted to show exact results from both experimental setups without the <code>Enum.random</code> call skewing the results?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144163" data-batch-url="/posts/batch_likers">
                        0
                      </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/looking-for-help-with-poor-ecto-query-performance/25476/43">Post #42</a>
	                </div>
	            </div>
              <div id="likers-container-144163" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144163"
                     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 #42"></div>
  </section>
</div>
    <div class="postbit" id="144164" data-post-id="144164">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="scouten" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scouten/120/2055_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  scouten
                    <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>Working on it as we speak …</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144164" data-batch-url="/posts/batch_likers">
                        0
                      </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/looking-for-help-with-poor-ecto-query-performance/25476/44">Post #43</a>
	                </div>
	            </div>
              <div id="likers-container-144164" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144164"
                     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 #43"></div>
  </section>
</div>
    <div class="postbit" id="144167" data-post-id="144167">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="scouten" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scouten/120/2055_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  scouten
                    <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>Now that I have that laptop connected to power again, I re-ran the results and have updated the repo with new numbers.</p>
<p>The O(n) on table size issue is gone. There’s still an absolute difference between Ecto and pgbench, but there are leads we can follow here as well.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144167" data-batch-url="/posts/batch_likers">
                        0
                      </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/looking-for-help-with-poor-ecto-query-performance/25476/45">Post #44</a>
	                </div>
	            </div>
              <div id="likers-container-144167" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144167"
                     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 #44"></div>
  </section>
</div>
    <div class="postbit" id="144168" data-post-id="144168">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Impressive progress. Please post the numbers when convenient, this saga is quite interesting and educational.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144168" data-batch-url="/posts/batch_likers">
                        6
                      </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/looking-for-help-with-poor-ecto-query-performance/25476/46">Post #45</a>
	                </div>
	            </div>
              <div id="likers-container-144168" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144168"
                     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 #45"></div>
  </section>
</div>
    <div class="postbit" id="144169" data-post-id="144169">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="scouten" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scouten/120/2055_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  scouten
                    <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, and I will do so. Hopefully this makes life a little easier for the next person who struggles with perf.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144169" data-batch-url="/posts/batch_likers">
                        6
                      </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/looking-for-help-with-poor-ecto-query-performance/25476/47">Post #46</a>
	                </div>
	            </div>
              <div id="likers-container-144169" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144169"
                     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 #46"></div>
  </section>
</div>
    <div class="postbit" id="144190" data-post-id="144190">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="scouten" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scouten/120/2055_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  scouten
                    <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>I’ve updated the repo with the results of experiments run during the day. We’re up to about 73% of <code>pgbench</code> performance on the update benchmark.</p>
<p>I’ve run <code>fprof</code> against the latest test harness and it looks like we’re now spending about 87% of the time waiting for messages from Postgres, so there’s probably not much more to squeeze out of this. The only thing that stands out for me is about 3% of time spent on logging (even though the test harness is configured not to produce logs).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144190" 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/looking-for-help-with-poor-ecto-query-performance/25476/48">Post #47</a>
	                </div>
	            </div>
              <div id="likers-container-144190" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144190"
                     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 #47"></div>
  </section>
</div>
    <div class="postbit" id="144220" data-post-id="144220">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/scouten" rel="nofollow">@scouten</a> what was the reason that you rolled your own little benchmarking library? Benchee has ways to call out to <code>Enum.random</code> that won’t affect the measured time (<a href="https://github.com/bencheeorg/benchee#hooks-setup-teardown-etc" rel="noopener nofollow ugc">hooks</a>) - if benchee added a throughput display would that be usable for you?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144220" 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/looking-for-help-with-poor-ecto-query-performance/25476/49">Post #48</a>
	                </div>
	            </div>
              <div id="likers-container-144220" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144220"
                     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 #48"></div>
  </section>
</div>
    <div class="postbit" id="144223" data-post-id="144223">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You can remove log calls completely from an application using <code>:compile_time_purge_matching</code>, it’s described <a href="https://hexdocs.pm/logger/Logger.html#module-application-configuration" rel="noopener nofollow ugc">here</a>.</p>
<p>That should remove those 3%. Note that it requires the application to be recompiled to have an effect (<code>mix deps.compile ecto --force</code> to be sure).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144223" 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/looking-for-help-with-poor-ecto-query-performance/25476/50">Post #49</a>
	                </div>
	            </div>
              <div id="likers-container-144223" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144223"
                     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 #49"></div>
  </section>
</div>
    <div class="postbit" id="144239" data-post-id="144239">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="scouten" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/scouten/120/2055_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  scouten
                    <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><a class="mention" href="/u/pragtob" rel="nofollow">@PragTob</a> I think benchee and my tool have different design intents. As you put it earlier in this thread:</p>
<blockquote>
<p>Benchee is concerned with measuring and providing data about the time it takes individual function calls to execute.</p>
</blockquote>
<p>I’m asking a different question with my tool: What is the <em>theoretical maximum write capacity</em> of a system that uses Elixir, Ecto, and Postgres together when under load? I still call it a “benchmarking tool,” but I’m starting to think it might be more accurate to refer to it as a load-generation tool.</p>
<p>IMHO the maximum write throughput of a Postgres system by itself on any given hardware is shown by <code>pgbench</code> by itself. Right now, I’m showing that a fairly rudimentary Elixir + Ecto application sustains about 73% of that theoretical capacity on the same hardware (a 2015-era MacBook Pro). There’s hope that with logging disabled, we might squeeze out a few more percentage points. (If there are more leads beyond that, I’m all ears!)</p>
<p>Armed with this data, I can now say to others on my team that we’re paying x% for logging, x% for checking out connections on each request, x% for Elixir/Ecto itself, etc., and we can have a discussion about whether these are reasonable costs and whether Elixir/Ecto/Postgres is an appropriate tech stack for our intended use case given our expected (hoped for) traffic.</p>
<p>This is obviously a very simple example. Internally, our situation is more complex and we’re seeing other perf problems that are probably rolled up in that complexity. The original intent of this tool was to mimic our PG system and allow me to layer on complexity, looking for that place where we lose performance.</p>
<p>I think I’ve got a “good enough” feel for baseline Ecto/Postgres write performance that I resume that next stage of the experiment (looking for the details of our internal issues).</p>
<p>Thanks, all, for your patience and help this week.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144239" 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/looking-for-help-with-poor-ecto-query-performance/25476/52">Post #51</a>
	                </div>
	            </div>
              <div id="likers-container-144239" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144239"
                     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 #51"></div>
  </section>
</div>
    <div class="postbit" id="144255" data-post-id="144255">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Results from running the tests on two Mac machines:</p>
<div class="md-table">
<table>
<thead>
<tr>
<th>CPU (cores/threads)</th>
<th>Test</th>
<th>IPS</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
<tr>
<td>Xeon-2150B, 10/20</td>
<td>Elixir create</td>
<td>27610</td>
<td>10s</td>
</tr>
<tr>
<td>Xeon-2150B, 10/20</td>
<td>pgbench create</td>
<td>32204</td>
<td>10s</td>
</tr>
<tr>
<td>Xeon-2150B, 10/20</td>
<td>Elixir update</td>
<td>41451</td>
<td>30s</td>
</tr>
<tr>
<td>Xeon-2150B, 10/20</td>
<td>pgbench update</td>
<td>135406</td>
<td>10s</td>
</tr>
<tr>
<td>i7-4870HQ, 4/8</td>
<td>Elixir create</td>
<td>17661</td>
<td>10s</td>
</tr>
<tr>
<td>i7-4870HQ, 4/8</td>
<td>pgbench create</td>
<td>29368</td>
<td>10s</td>
</tr>
<tr>
<td>i7-4870HQ, 4/8</td>
<td>Elixir update</td>
<td>23242</td>
<td>30s</td>
</tr>
<tr>
<td>i7-4870HQ, 4/8</td>
<td>pgbench update</td>
<td>47860</td>
<td>10s</td>
</tr>
</tbody>
</table>
</div><hr>
<p>One thing that struck me as odd that out of all 4 tests, 1 of them has a 30s duration (the Elixir update one) and the rest are all at 10s. Why is that?</p>
<p>Another thing I don’t like about the tests is the inconsistency of the inserted data coming from <code>:rand.uniform()</code>. I would create an ETS table or an in-memory list with 100k pre-calculated random values and would reuse that in all tests (all 4, one after another). Not sure how I’d code that yet.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="144255" data-batch-url="/posts/batch_likers">
                        0
                      </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/looking-for-help-with-poor-ecto-query-performance/25476/55">Post #54</a>
	                </div>
	            </div>
              <div id="likers-container-144255" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="144255"
                     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 #54"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/25476/load_more?page=6">Load more posts (32 remaining)</a>
</div></template></turbo-stream>