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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Even for projects not having the issue above, then there is a noticeable performance improvements from 1.19.4 to 1.19.5</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="381567" 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/elixir-1-19-compilation-performance-have-you-noticed-a-difference/73030/23">Post #22</a>
	                </div>
	            </div>
              <div id="likers-container-381567" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="381567"
                     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="382856" data-post-id="382856">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="rutgerdj" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  rutgerdj
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ve noticed that in our project the verification step of the Phoenix router takes significantly longer than on 1.18. From lless than a second to more  than 10 seconds.<br>
This is specifically noticable when the code live-reloads because of a change in the live_views</p>
<p>Im now regularly getting these messages in console:<br>
<code>Verifying CvsWeb.Router (it’s taking more than 10s)</code></p>
<p>This only happens when changing live_<strong>views</strong>. Live_<strong>components</strong> are fine and don’t cause this slowdown.</p>
<p>Our suspicion was that the issue is due to the large Cycle that occurs in the Phoenix router. (this seems to be a known issue: <a href="https://github.com/phoenixframework/phoenix/issues/6522" class="inline-onebox" rel="noopener nofollow ugc">Verified routes feature is pathological in terms of compile-connected cycles. · Issue #6522 · phoenixframework/phoenix · GitHub</a>)</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&gt;  mix xref graph  --format cycles          
2 cycles found. Showing them in decreasing size:

Cycle of length 106:
.. modules omitted ..

Cycle of length 7:
.. modules omitted ..
</code></pre>
<p>But after removing references to verified_route and bringing down the cycle count from 106 to 6 it’s still slow.<br>
We’re seeing these issues on 1.19.1, tried upgrading to 1.19.5 but that didn’t change anything.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="382856" 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/elixir-1-19-compilation-performance-have-you-noticed-a-difference/73030/24">Post #23</a>
	                </div>
	            </div>
              <div id="likers-container-382856" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="382856"
                     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="382858" data-post-id="382858">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="josevalim" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/120/1787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  josevalim
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Elixir</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group quote-modified" data-username="rutgerdj" data-post="24" data-topic="73030">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/r/90ced4/48.png" class="avatar"> rutgerdj:</div>
<blockquote>
<p>Our suspicion was that the issue is due to the large Cycle that occurs in the Phoenix router. (this seems to be a known issue: <a href="https://github.com/phoenixframework/phoenix/issues/6522" rel="nofollow">Verified routes feature is pathological in terms of compile-connected cycles. · Issue #6522 · phoenixframework/phoenix · GitHub</a>)</p>
</blockquote>
</aside>
<p>I have replied to the issue, but as far as I know, the issue seems to be a false positive: VerifiedRoutes do not add compile-time dependencies to the router. From your description, it seems to be an issue in the verification code itself, an unexpected slow down, rather than something symtomatic, but it is hard to say without the context given.</p>
<p>My suggestion is to either:</p>
<ol>
<li>debug and measure where the time is spent in the verification code</li>
<li>provide a minimal reproduction case</li>
</ol> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="382858" 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/elixir-1-19-compilation-performance-have-you-noticed-a-difference/73030/25">Post #24</a>
	                </div>
	            </div>
              <div id="likers-container-382858" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="382858"
                     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="382898" data-post-id="382898">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="rutgerdj" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  rutgerdj
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’ve narrowed down the verification slowdown in the Phoenix router to the <code>Module.Types.Desc.tuple_empty?/1</code> function.</p>
<p>Profiling indicates most of the time is spent calculating warnings in <a href="https://github.com/elixir-lang/elixir/blob/d33fd8e413fe98e0e54dde7ef94fadb272b1ef67/lib/elixir/lib/module/parallel_checker.ex#L281-L286" rel="noopener nofollow ugc">parallel_checker.ex</a>, specifically within the Expr.of_expr call in <a href="https://github.com/elixir-lang/elixir/blob/d33fd8e413fe98e0e54dde7ef94fadb272b1ef67/lib/elixir/lib/module/types.ex#L320C1-L321C69" rel="noopener nofollow ugc">Module.Types</a>.</p>
<p>I added instrumentation to Module.Types.Desc.tuple_empty?/1 and found a large number of calls:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># Total time is &gt; 10s even without instrumentation overhead
[Descr Instrumentation Report]
  tuple_empty? calls:           4725510
  tuple_empty? total time:      17445.936ms
  tuple_line_empty? calls:      33037288
  tuple_elements_empty? calls:  40118070
  intersection calls:           40118070
  difference calls:             40118070
  max tuple elements seen:      4
  max negations count:          15
</code></pre>
<p>It appears the bottleneck is caused by the large number of calls to <code>tuple_line_empty?</code> and <code>tuple_elements_empty?</code></p>
<p>update:<br>
I’ve found that the number of calls to <code>tuple_empty?/1</code> grows exponentially (roughly 2x) for every <code>def on_mount(...)</code> clause in our UserAuth module. Since we have about 11 of those clauses the number of calls really explodes</p>
<p>This behavior seems tied to how ash_authentication_phoenix interacts with live_session. When using standard Phoenix live_session blocks, the number of calls to these stays constant in relationship to the number of clauses in the UserAuth module.</p>
<p>I will create a minimal reproduction repo to demonstrate the issue</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="382898" data-batch-url="/posts/batch_likers">
                        3
                      </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/elixir-1-19-compilation-performance-have-you-noticed-a-difference/73030/26">Post #25</a>
	                </div>
	            </div>
              <div id="likers-container-382898" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="382898"
                     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 #25"></div>
  </section>
</div>
    <div class="postbit" id="382916" data-post-id="382916">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="rutgerdj" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  rutgerdj
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here is a minimal reproduction repo:<br>
<a href="https://github.com/Rutgerdj/elixir-slow-router-verification-reprod" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/Rutgerdj/elixir-slow-router-verification-reprod</a></p>
<p>You can change the <code>@total_on_mount_clauses</code> to see the result.<br>
Even without using the modified elixir version with instrumentation you will notice a significant difference between 4 and 16 clauses.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="382916" data-batch-url="/posts/batch_likers">
                        3
                      </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/elixir-1-19-compilation-performance-have-you-noticed-a-difference/73030/27">Post #26</a>
	                </div>
	            </div>
              <div id="likers-container-382916" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="382916"
                     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 #26"></div>
  </section>
</div>
    <div class="postbit" id="383043" data-post-id="383043">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="josevalim" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/josevalim/120/1787_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  josevalim
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Elixir</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Thank you, this was a very well done sample app! I can no longer reproduce the issue as of v1.20.0-rc.1. Can you confirm that’s the case for you too?</p>
<p>Btw, regarding the 16 clauses, we simplify inferred code once it has more than 16 clauses… <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="383043" 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/elixir-1-19-compilation-performance-have-you-noticed-a-difference/73030/29">Post #28</a>
	                </div>
	            </div>
              <div id="likers-container-383043" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="383043"
                     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 #28"></div>
  </section>
</div>
    <div class="postbit" id="383050" data-post-id="383050">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="rutgerdj" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  rutgerdj
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>The issue is gone in the reproduction repo for me too.<br>
On our real project the performance has improved significantly from above 10s to something around 3 seconds<br>
However, if I add a few extra clauses (taking the total to 15) it is still slow, not as slow as it was on 1.19, but above 10 seconds.</p>
<p>Will see if I can figure out what’s causing it</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="383050" 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/elixir-1-19-compilation-performance-have-you-noticed-a-difference/73030/30">Post #29</a>
	                </div>
	            </div>
              <div id="likers-container-383050" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="383050"
                     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>