A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » why malloc on linux(pc) is faster than aix(IBM p5)?

#1 2009-01-16 09:29 AM


Re: why malloc on linux(pc) is faster than aix(IBM p5)?

I did a simple test on a IBM system P5 (aix5.3) and  normal PC (linux RHEL5):

loop 20,000, 000 times, 
in every loop  I alloc 256byte memory and then free it.

I just do this simple test on aix5.3 and linux RHEL5, and I drawed the conclusion: "Malloc on linux is much faster  on aix!"
because the exhaust time of the same test on linux is only about 1/3 as on AIX!

and  I tried set env variables like MALLOCOPTIONS and tested very values,  but the result still has no change.

Could anyone give me some advices?

#2 2009-01-16 02:26 PM

From: Boston, MA
Registered: 2002-06-12
Posts: 3,839

Re: why malloc on linux(pc) is faster than aix(IBM p5)?

Um, I'm not sure what kind of "advice" you want?  What is it you wish to DO, exactly?
Make AIX's malloc() as fast as Linux's?  That may simply not be possible...  It could
just be that Linux has a superior malloc() implementation...  If that's all it is, you could
theoretically port it to AIX and use it instead of the native libc one there...  However, it
could instead be that the Linux syscalls used by malloc() (brk(), mmap(), etc.) are
simply more efficient, in which case you'd have a very hard time porting THEM over
to AIX (unless you have the kernel source, anyway)...

Or, have you considered it may simply be the hardware that's responsible for the
difference?  Maybe the Linux PC is simply far faster than the AIX machine?

Just for the hell of it, try doing a calloc() instead of malloc(), and see if the results are
still so wildly different...  On Linux, at least, malloc() doesn't actually allocate any true
memory to you until you access it; calloc() will clear it, so force it to really all be given
to you at the time...  Of course, I doubt that'll matter, if you're just talking about 256 byte
chunks...  It'd be more of a possible issue if you were allocating really large amounts
(or, perhaps not free()'ing after every malloc())...


#3 2009-01-17 02:44 AM

From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: why malloc on linux(pc) is faster than aix(IBM p5)?

Do the same test with Linux on that P5 before drawing any conclusions...

Anyway, your program shouldn't be limited by malloc/free speed anyway.
If it is, you might need to readjust some things, like avoiding calling malloc
so often.


  • Index
  • » C
  • » why malloc on linux(pc) is faster than aix(IBM p5)?

Board footer

Powered by FluxBB