<div dir="ltr"><div class="gmail_default" style="font-family:arial narrow,sans-serif"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 2, 2016 at 12:51 PM, Michael Ulitskiy <span dir="ltr"><<a href="mailto:mulitskiy@acedsl.com" target="_blank">mulitskiy@acedsl.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div style="font-family:'Sans Serif';font-size:11pt;font-weight:400;font-style:normal">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Hello,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Since you started to look at it again, let me repeat myself.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">The problem is described in detail here: <a href="http://lists.digium.com/pipermail/asterisk-dev/2015-October/075128.html" target="_blank">http://lists.digium.com/pipermail/asterisk-dev/2015-October/075128.html</a></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">It has to do with the fact that at initial load pjsip realtime issues separate db query for each endpoint/aor/etc in the system.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">In my case of ~10K endpoints it took asterisk ~1.5minutes to load.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Further in that discussion I suggested that having the following API call to populate sorcery cache would go a long way to </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">reducing the scale of this problem:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:'Courier New,courier'">ast_sorcery_retrieve_by_fields(sip_sorcery, "endpoint",AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">I haven't looked at pjsip since the time of that discussion as that's clearly a show-stopper for me, but I doubt anything changed.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Also I haven't received any feedback if that suggestion is viable, so I'd love to hear your (and/or other developers) opinion on it.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Any other idea on how to deal with it is more than welcome as well.</p></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:'arial narrow',sans-serif">​So part of this I just fixed in review 2312.  The cache is now populated at startup.  Together with full_backend_cache there should be *some* relief.  </div><div class="gmail_default" style="font-family:'arial narrow',sans-serif"><br></div><div class="gmail_default" style="font-family:'arial narrow',sans-serif">One of the base issues however is that we can't use the power of SQL to narrow down the result set before shipping them all back to Asterisk because not all the backends support SQL.  If they did, we could, for instance, 'select * from ps_endpoints a, ps_aors b where <a href="http://a.id">a.id</a> = <a href="http://b.id">b.id</a> and b.qualify_frequency > 0' (well almost) to get only the endpoints that need to be scheduled.  Or 'select * from ps_endpoints where id in ('user','user@domain')'.  We just can't do that right now.</div><div class="gmail_default" style="font-family:'arial narrow',sans-serif"><br></div><div class="gmail_default" style="font-family:'arial narrow',sans-serif">All is not lost however.  We've been noodling with some ideas on how to make this work more efficiently but it's not something that's going to happen this week, :)</div><div class="gmail_default" style="font-family:'arial narrow',sans-serif"><span style="font-family:arial,sans-serif"> </span><br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:'Sans Serif';font-size:11pt;font-weight:400;font-style:normal">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Thanks,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Michael</p><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br></p></span></div></blockquote></div></div></div>