Just a minor new twist on free()

Richard Minner rtm at christmas.UUCP
Mon Oct 8 15:31:34 AEST 1990


In article <8026 at scolex.sco.COM> seanf (Sean Fagan) writes:
>In article <PDS.90Oct3103126 at lemming.webo.dg.com> pds at lemming.webo.dg.com (Paul D. Smith) writes:
>>Now, *this* is a significant performance hit, if you consider an extra
>>10000 comparisons.  
>And now an ANSI compliant library must have free() check for a NULL
>parameter, which means that, instead of 10000 tests, you are now doing 20000
>tests.  Yep.  Just love those performance increases, don't you?

Sorry, I just can't stand it anymore.  This is about the fourth or fifth
posting talking about `performance' in this way.  Isn't someone going
to comment?  (I guess I am.)

Quick Quiz:  Is saving an hour of CPU time significant?
		a) Yes  b) No  c) Not enough information

If you answered a) or b), go back and re-read the chapter on performance
and efficiency.  If you don't consider the whole job, you can't talk
about performance in any meaningful way.  E.g. go to Bank of America
and tell them how you can save them an hour of CPU time each year. 
I don't think they'll be very impressed.  Tell me how I can cut my
image conversion from 80 minutes to 20 and you'll have my full attention.
Tell me how I can cut my nightly batch job from 80 minutes to 20 and
I might be curious, but won't really care.

Please stop talking about `10000 comparisons' as if it meant something.
I'm sorry, but you might as well make it 10 million; performance is
relative.  The time for one more `if' is not signifcant compared to
the rest of the work free() has to do.  (If you have an implementation
of free() for which one test *is* significant, I'd like to know about
it.  By the way, I don't consider 1% very significant.)

As someone recently mentioned, the big performance gains are from
good algorithms and design; shaving instructions is the last concern
and only when you have good reason to believe you are doing so in
a very critical portion of the code.  For example, if you have to
do 10000 allocations/frees where performance matters, you're probably
going to want your own memory manager tuned to your needs, rather than
using malloc/free which are quite general and often not the most efficient
for a particular task.

The ANSI behavior for free() is a good thing.  I don't want to read
any more complaints about it ;-)


-- 
Richard Minner  || {uunet,sun,well}!island!rtm     (916) 736-1323 ||
                || Island Graphics Corporation     Sacramento, CA ||



More information about the Comp.lang.c mailing list