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

Richard Mudgett asteriskteam at digium.com
Tue Mar 6 10:29:30 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.
 > >
 > > 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.
 > 
 > I ran the test as well but with DONT_OPTIMIZE and MALLOC_DEBUG
 > disabled.  My results were pretty consistent between iterations in
 > each configuration so I'm only posting the total runtimes:
 > 
 > Without patch: 8874ms with the test in main/asterisk.c, 9028ms with
 > the test in a module.
 > With this patch: 8918ms with the test in main/asterisk.c, 9290ms
 > with the test in a module.
 > With my followup: 9345ms with the test in main/asterisk.c, 9409ms
 > with the test in a module.
 > 
 > This means 100 million pairs of calls to ast_malloc/ast_free will
 > take 50-250ms longer with Richard's patch, 400-500ms longer when my
 > followup is included.  I'm unsure why my patch causes the runtime
 > to increase, it actually eliminates an extra function call layer. 
 > This leads me to wonder if optimization is bypassing the
 > __ast_repl_malloc function in Richard's patch and causing it to be
 > inlined.

I can see how __ast_repl_malloc() can become simply an alias for malloc()
when optimization is enabled.  Given that the caller cleans up the passed
parameters in C and the first parameter to __ast_repl_malloc() is the same
as the parameter to malloc() then the address of __ast_repl_malloc could
simply be made the same as malloc().


-- 
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 16:29:30 +0000
Gerrit-HasComments: No
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180306/2310c77c/attachment.html>


More information about the asterisk-code-review mailing list