<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/22106">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">AllocTest: Avoid queuing tons of to-be-freed ms<br><br>When both TBFs (Dl, Ul), are detached, ms_detach_tbf() will call<br>ms_start_timer() which will hold a reference of the MS (ms_ref()) and<br>wait for X seconds (VTY config, T=-2030, 60 seconds by default) before<br>unrefing the MS, which will trigger ms_update_status() finally (ref==0)<br>and will in turn call cb.ms_idle(), which will tell the ms_storage to<br>free the MS.<br><br>This mechanism is used to keep MS objects around for a certain time so<br>that when new TBFs are established, we have cached interesting<br>information about the MS, ready to use.<br><br>However, in AllocTest, tons of MS are allocated in a loop calling a<br>function (such as test_alloc_b_ul_dl()). In that function, a BTS is<br>allocated in the stack and at the end of the function BTS::cleanup() is<br>called due to implicit destructor, which ends up calling<br>ms_storage::cleanup() which removes all MS from its list and frees them<br>*if they are not idle*. The problem here, is that due to T=-2030, an<br>extra reference is hold and hence the ms is not considered idle<br>(ms_is_idle() checks ms->ref==0). As a result, the MS is never freed,<br>because we don't use libosmocore mainloop here (and in any case, it<br>would take 60 seconds to free it).<br><br>By setting the timeout of T=-2030 to 0, ms_start_timer will avoid using<br>the timer and will also avoid holding the extra reference, hence<br>allowing ms_storage to free the object during cleanup().<br><br>This fix really helps in improving performance for AllocTest specially<br>after MS object contains a rate_ctr. As tons of MS objects were left<br>alive, they stood in the rate_ctr single per-process queue, making the<br>test last crazy amount of time and spending 50% of the time or more<br>iterating the list full of MS related rate counters.<br><br>Change-Id: I6b6ebe8903e4fe76da5e09b02b6ef28542007b6c<br>---<br>M tests/alloc/AllocTest.cpp<br>1 file changed, 6 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/06/22106/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp</span><br><span>index 17cee46..85c3527 100644</span><br><span>--- a/tests/alloc/AllocTest.cpp</span><br><span>+++ b/tests/alloc/AllocTest.cpp</span><br><span>@@ -219,6 +219,8 @@</span><br><span>      enable_ts_on_bts(bts, ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7);</span><br><span> </span><br><span>   ms = the_bts.ms_alloc(ms_class, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Avoid delaying free to avoid tons of to-be-freed ms objects queuing */</span><br><span style="color: hsl(120, 100%, 40%);">+     ms_set_timeout(ms, 0);</span><br><span>       ul_tbf = tbf_alloc_ul_tbf(bts, ms, -1, true);</span><br><span>        if (!ul_tbf)</span><br><span>                 return false;</span><br><span>@@ -262,6 +264,8 @@</span><br><span>  enable_ts_on_bts(bts, ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7);</span><br><span> </span><br><span>   ms = the_bts.ms_alloc(ms_class, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Avoid delaying free to avoid tons of to-be-freed ms objects queuing */</span><br><span style="color: hsl(120, 100%, 40%);">+     ms_set_timeout(ms, 0);</span><br><span>       dl_tbf = tbf_alloc_dl_tbf(bts, ms, -1, true);</span><br><span>        if (!dl_tbf)</span><br><span>                 return false;</span><br><span>@@ -314,6 +318,8 @@</span><br><span>  tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);</span><br><span>    OSMO_ASSERT(tfi >= 0);</span><br><span>    ms = the_bts.ms_alloc(ms_class, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Avoid delaying free to avoid tons of to-be-freed ms objects queuing */</span><br><span style="color: hsl(120, 100%, 40%);">+     ms_set_timeout(ms, 0);</span><br><span>       ul_tbf = tbf_alloc_ul_tbf(bts, ms, -1, false);</span><br><span>       if (!ul_tbf)</span><br><span>                 return false;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/22106">change 22106</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-pcu/+/22106"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I6b6ebe8903e4fe76da5e09b02b6ef28542007b6c </div>
<div style="display:none"> Gerrit-Change-Number: 22106 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>