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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="9" data-topic="21124" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>The intervals are not regular afaik, but that would be a cool idea, I admit!</p>
</blockquote>
</aside>
<p>So unless you have the special case of a bounded range with known discrete values, I think you’re stuck with O(log(n)) no matter where the dispatch is done. If you do have that special case, you could build the complete hash table for all values. If not, something like a B-tree would be most efficient, but I think you’d need a NIF to do that 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="121562" 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/module-with-too-many-functions-exausts-erlang-atoms/21124/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-121562" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121562"
                     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 #11"></div>
  </section>
</div>
    <div class="postbit" id="121570" data-post-id="121570">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Fl4m3Ph03n1x" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Fl4m3Ph03n1x/120/11709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Fl4m3Ph03n1x
                    <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 group-Erlang-Core-Team" data-username="bjorng" data-post="10" data-topic="21124">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bjorng/48/13187_2.png" class="avatar"> bjorng:</div>
<blockquote>
<p>Do you really mean 10 million functions or one function with 10 million clauses?</p>
<p>I think it would be useful if you could provide an example more similar to how your real code would look like.</p>
</blockquote>
</aside>
<p>We tested 2 scenarios:</p>
<ol>
<li>Module with 100_000 functions</li>
<li>Module with 1 function that has 100_000 clauses</li>
</ol>
<p>Since we decreased the order of magnitude, both samples worked. The second test (1 function with many clauses) was faster but the main point is that both work.</p>
<p>So, picking on the results of the second test, we increased the order of magnitude by 1 ( 1_000_000 ). Instead of taking a minute or so to compile, it puts the RAM on fire and stays compiling forever.</p>
<p>It should have taken 10 times more time to compile, but instead it seems it just gets stuck. We are now testing the following approach: <strong>Several modules, each with a function containing 100_000 clauses</strong>.</p>
<p>Will let you guys know how it goes.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121570" 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/module-with-too-many-functions-exausts-erlang-atoms/21124/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-121570" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121570"
                     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 #12"></div>
  </section>
</div>
    <div class="postbit" id="121609" data-post-id="121609">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi, we encountered a similar situation and the solution we went for was to define functions in dynamically generated modules (Foo_132).</p>
<p>The sweet spot for our use case was around 800 function clauses per module/file. At the same time we kept track of where each clause was defined, and created a central module that delegated to the dynamically generated ones, to give ourselves a sane interface. The final generated code looked something like that</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Foo do
  def foo(132), do: Foo_132.foo(132)
end
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121609" data-batch-url="/posts/batch_likers">
                        4
                      </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/module-with-too-many-functions-exausts-erlang-atoms/21124/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-121609" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121609"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="121705" data-post-id="121705">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ferd" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ferd/120/12731_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ferd
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Property-Based Testing with PropEr, LYSE, &amp; Erlang in Anger</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I don’t really know how to answer to this in a reasonable way, but <em>why</em> would modules with 10,000,000 functions be the appropriate tool for the job?</p>
<p>Particularly if you need special build machines just to accommodate potentially compiling the thing and keep running into limitations of the runtime environment you’re using, I would be led to believe that you need a different tool than the one that keeps breaking and failing to do what you want it to do.</p>
<p>Is there a different approach that you could take, or maybe you found a problem that’s just not a good fit for the VM? This sounds like a nightmare.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121705" data-batch-url="/posts/batch_likers">
                        12
                      </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/module-with-too-many-functions-exausts-erlang-atoms/21124/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-121705" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121705"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="121715" data-post-id="121715">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yeah, fair to ask why not a tree of anon functions–two reasons I can think of: a belief that compiler machinery will result in something that dispatches faster, or a need for fast startup times…</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121715" 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/module-with-too-many-functions-exausts-erlang-atoms/21124/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-121715" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121715"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="121725" data-post-id="121725">
  <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>The compiler machinery does result in something that dispatches faster – but you are hitting its limits.</p>
<p>I’d go for what <a class="mention" href="/u/bottlenecked" rel="nofollow">@bottlenecked</a> did: use a tree with a quick dispatch mechanism. If you insist on using Erlang/Elixir for this task then that’s what’s going to work best. Have 500-1000 functions per module and you should be set.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121725" 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/module-with-too-many-functions-exausts-erlang-atoms/21124/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-121725" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121725"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="121730" data-post-id="121730">
  <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>I really second this.</p>
<p>If no “normal” data structure can satisfy your needs maybe it’s time to investigate other tools?</p>
<p>This small component seems super critical from what you say - have you looked at doing it in Rust/something bare metal you could then call out to via rustler/NIFs?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="121730" 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/module-with-too-many-functions-exausts-erlang-atoms/21124/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-121730" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="121730"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="122560" data-post-id="122560">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Fl4m3Ph03n1x" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Fl4m3Ph03n1x/120/11709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Fl4m3Ph03n1x
                    <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 group-Rebar3" data-username="ferd" data-post="15" data-topic="21124" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ferd/48/12731_2.png" class="avatar"> ferd:</div>
<blockquote>
<p>I don’t really know how to answer to this in a reasonable way, but <em>why</em> would modules with 10,000,000 functions be the appropriate tool for the job?</p>
<p>Particularly if you need special build machines just to accommodate potentially compiling the thing and keep running into limitations of the runtime environment you’re using, I would be led to believe that you need a different tool than the one that keeps breaking and failing to do what you want it to do.</p>
<p>Is there a different approach that you could take, or maybe you found a problem that’s just not a good fit for the VM? This sounds like a nightmare.</p>
</blockquote>
</aside>
<p>This is a good question. We are dealing with searching for IPs within given ranges, so we have a couple of options:</p>
<ol>
<li>Put the ips into a DB and make requests to such DB</li>
<li>Have this information in another tool/binary and have Elixir interact with it</li>
</ol>
<p>Solution 1 has long query times for our needs. No only that, it also adds uncertainty (connections to the DB can fail) and an extra technology to our stack which we will have to maintain on the long run.</p>
<p>Solution 2 is better in that the query times can be dozens of times faster (no network traffic, no need to ask for a DB engine to perform a query) but it would force us to use the <code>Port</code> module to communicate with the given extra binary and it would still force us to keep and update a different technology on the long run.</p>
<p>Having this in Elixir would offer the following benefits:</p>
<ol>
<li>faster access than previous solutions</li>
<li>we keep the stack we are already using small and consise</li>
<li>easy to maintain and use</li>
</ol>
<p>Yes, compilation is an issue, but we only need to do it once and then we just add this as a project dependency to whoever needs using (we have something like private Hex for our libraries and packages, so we have some level of versioning and releases ).</p>
<aside class="quote no-group" data-username="PragTob" data-post="18" data-topic="21124">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/pragtob/48/2401_2.png" class="avatar"> PragTob:</div>
<blockquote>
<p>This small component seems super critical from what you say - have you looked at doing it in Rust/something bare metal you could then call out to via rustler/NIFs?</p>
</blockquote>
</aside>
<p>We are working on the assumption several modules, each with thousands of functions, would give us faster results than using the appropriate data structure for the problem (interval trees).  How do we know this is the case? We don’t, we simply assume, based on our current knowledge, this will beat the complexity of having an interval tree. We could be totally off, but we won’t know until we benchmark it.</p>
<p>And as I previously stated, we want to keep our technology stack small. This is critical part of our system that we will have to maintain in years to come. Rust and NIFs look cool but if we don’t have the personal to keep it oiled and running we will run into issues. It is, in the end, a company decision, which I understand.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="122560" 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/module-with-too-many-functions-exausts-erlang-atoms/21124/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-122560" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="122560"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="122563" data-post-id="122563">
  <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">
								<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="19" data-topic="21124">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>We are working on the assumption several modules, each with thousands of functions, would give us faster results than using the appropriate data structure for the problem (interval trees)</p>
</blockquote>
</aside>
<p>In the end even the modules with their functions is also some kind of data structure that just points into the right spot. One could probably build this by hand or attempt the same thing in another language and see if it fares better at the task than elixir.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="19" data-topic="21124">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>We could be totally off, but we won’t know until we benchmark it.</p>
</blockquote>
</aside>
<p>That’s the key point here imo. Even for a smaller/somewhat manageable number I’d advise to write benchmarks to see how different solutions fare.</p>
<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="19" data-topic="21124">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>Rust and NIFs look cool but if we don’t have the personal to keep it oiled and running we will run into issues.</p>
</blockquote>
</aside>
<p>I obviously don’t know your system, my assumption is that it’s a small performance relevant component of your system. If so, doing it in another language (be it via NIF, ports or HTTP calls micro service style) shouldn’t be too much of a hassle. My assumption also being that the code wouldn’t need to change too often. Rust, as an example, is very much focussed on backwards compatibility so it shouldn’t incur too much friction.</p>
<p>In the end it’s a trade off as always, rather a thing in language X that works or jump through a lot of hoops to maybe make it work on the BEAM?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="122563" 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/module-with-too-many-functions-exausts-erlang-atoms/21124/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-122563" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="122563"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="122564" data-post-id="122564">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Qqwy" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Qqwy/120/1349_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Qqwy
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>TypeCheck Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Fl4m3Ph03n1x" data-post="19" data-topic="21124">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/48/11709_2.png" class="avatar"> Fl4m3Ph03n1x:</div>
<blockquote>
<p>We are dealing with searching for IPs within given ranges,</p>
</blockquote>
</aside>
<p>Because of the fact that there are  3.4*10³⁸ possible addresses in IPv6, I am wondering about the rest of your constraints that make you believe that, unless your ranges are very convenient, you could fit this in a 10⁶ lookup table?</p>
<p>Instead, maybe it is worth looking into bloom filters (combined with a somewhat slower but more scalable access method like for instance ETS).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="122564" 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/module-with-too-many-functions-exausts-erlang-atoms/21124/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-122564" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="122564"
                     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 #20"></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/21124/load_more?page=3">Load more posts (5 remaining)</a>
</div></template></turbo-stream>