[Asterisk-code-review] core: Remove ABI effects of MALLOC DEBUG. (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Mon Mar 5 18:08:26 CST 2018


Richard Mudgett has posted comments on this change. ( https://gerrit.asterisk.org/8366 )

Change subject: core: Remove ABI effects of MALLOC_DEBUG.
......................................................................


Patch Set 4:

> I understand that but knowing the repercussions of it is a good
 > thing.

#define TEST_RUNS           10
#define REPETITION_COUNT    10000000U

    for (run = TEST_RUNS; run--;) {
        unsigned count;
        struct timeval start;
        struct timeval end;
        void *mem;
        int64_t us;

        start = ast_tvnow();
        for (count = REPETITION_COUNT; count--;) {
            mem = ast_malloc(4000);
            ast_free(mem);
        }
        end = ast_tvnow();

        us = ast_tvdiff_us(end, start);

        ast_test_status_update(test, "Executed malloc/free %u times in %ld us\n",
            REPETITION_COUNT, (long int) us);
        avg += us;
    }
    ast_test_status_update(test, "Average malloc/free time %ld us\n",
        (long int) (avg / TEST_RUNS));

I created a unit test with the above loop to generate the results below.
I expected the patch to slow execution some because of the extra function
call layer.  However, I frequently saw reported execution times with and
without the patch being consistently about a second higher.  It made it
very difficult to get believable results to compare with and without the
patch when I compiled it one way and it returned higher times than the
last time.


Executed without the patch, DONT_OPTIMIZE, and no MALLOC_DEBUG

*CLI> test execute category /utils/malloc/
Running all available tests matching category /utils/malloc/

START  /utils/malloc/ - malloc performance
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2792979 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2625359 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2628696 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2627449 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2625525 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2630267 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2624641 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2627755 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2626688 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2637583 us
[test_malloc.c:test_malloc:84]: Average malloc/free time 2644694 us
END    /utils/malloc/ - malloc performance Time: 26447ms Result: PASS

1 Test(s) Executed  1 Passed  0 Failed


Executed with the patch, DONT_OPTIMIZE, and no MALLOC_DEBUG

*CLI> test execute category /utils/malloc/
Running all available tests matching category /utils/malloc/

START  /utils/malloc/ - malloc performance
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2742066 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2739642 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2739275 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2736473 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2738720 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2737957 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 3186403 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 3618390 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2736889 us
[test_malloc.c:test_malloc:80]: Executed malloc/free 10000000 times in 2739614 us
[test_malloc.c:test_malloc:84]: Average malloc/free time 2871542 us
END    /utils/malloc/ - malloc performance Time: 28715ms Result: PASS

1 Test(s) Executed  1 Passed  0 Failed


-- 
To view, visit https://gerrit.asterisk.org/8366
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ic07ad80b2c2df894db984cf27b16a69383ce0e10
Gerrit-Change-Number: 8366
Gerrit-PatchSet: 4
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Comment-Date: Tue, 06 Mar 2018 00:08:26 +0000
Gerrit-HasComments: No
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180305/b4bc3bb5/attachment.html>


More information about the asterisk-code-review mailing list