<p>Richard Mudgett <strong>posted comments</strong> on this change.</p><p><a href="https://gerrit.asterisk.org/8366">View Change</a></p><p>Patch set 4:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">I understand that but knowing the repercussions of it is a good<br>thing.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">#define TEST_RUNS 10<br>#define REPETITION_COUNT 10000000U</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> for (run = TEST_RUNS; run--;) {<br> unsigned count;<br> struct timeval start;<br> struct timeval end;<br> void *mem;<br> int64_t us;</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> start = ast_tvnow();<br> for (count = REPETITION_COUNT; count--;) {<br> mem = ast_malloc(4000);<br> ast_free(mem);<br> }<br> end = ast_tvnow();</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> us = ast_tvdiff_us(end, start);</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> ast_test_status_update(test, "Executed malloc/free %u times in %ld us\n",<br> REPETITION_COUNT, (long int) us);<br> avg += us;<br> }<br> ast_test_status_update(test, "Average malloc/free time %ld us\n",<br> (long int) (avg / TEST_RUNS));</pre><p style="white-space: pre-wrap; word-wrap: break-word;">I created a unit test with the above loop to generate the results below.<br>I expected the patch to slow execution some because of the extra function<br>call layer. However, I frequently saw reported execution times with and<br>without the patch being consistently about a second higher. It made it<br>very difficult to get believable results to compare with and without the<br>patch when I compiled it one way and it returned higher times than the<br>last time.</p><p style="white-space: pre-wrap; word-wrap: break-word;"><br>Executed without the patch, DONT_OPTIMIZE, and no MALLOC_DEBUG</p><p style="white-space: pre-wrap; word-wrap: break-word;">*CLI> test execute category /utils/malloc/<br>Running all available tests matching category /utils/malloc/</p><p style="white-space: pre-wrap; word-wrap: break-word;">START /utils/malloc/ - malloc performance<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2792979 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2625359 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2628696 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2627449 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2625525 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2630267 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2624641 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2627755 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2626688 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2637583 us<br>[test_malloc.c:test_malloc:84]: Average malloc/free time 2644694 us<br>END /utils/malloc/ - malloc performance Time: 26447ms Result: PASS</p><p style="white-space: pre-wrap; word-wrap: break-word;">1 Test(s) Executed 1 Passed 0 Failed</p><p style="white-space: pre-wrap; word-wrap: break-word;"><br>Executed with the patch, DONT_OPTIMIZE, and no MALLOC_DEBUG</p><p style="white-space: pre-wrap; word-wrap: break-word;">*CLI> test execute category /utils/malloc/<br>Running all available tests matching category /utils/malloc/</p><p style="white-space: pre-wrap; word-wrap: break-word;">START /utils/malloc/ - malloc performance<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2742066 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2739642 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2739275 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2736473 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2738720 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2737957 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 3186403 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 3618390 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2736889 us<br>[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2739614 us<br>[test_malloc.c:test_malloc:84]: Average malloc/free time 2871542 us<br>END /utils/malloc/ - malloc performance Time: 28715ms Result: PASS</p><p style="white-space: pre-wrap; word-wrap: break-word;">1 Test(s) Executed 1 Passed 0 Failed</p><ul style="list-style: none; padding-left: 20px;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/8366">change 8366</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.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.asterisk.org/8366"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: Ic07ad80b2c2df894db984cf27b16a69383ce0e10 </div>
<div style="display:none"> Gerrit-Change-Number: 8366 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Tue, 06 Mar 2018 00:08:26 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>