Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performance of the Darwin 6.6 Libc malloc()



> It might do - if malloc handles requests larger than a certain size by
> simply getting a new block of memory that size from the kernel. AIUI, the
> kernel doesn't actually grab any pages of VM at this point, it merely
> records in some list that a certain number are needed when the memory's
> actually used. If the cost of recording the request is cheap enough, then
> doing a large malloc without touching the contents of the allocated region
> approaches a no-op.

This is a very good distinction. The intent of the test was to time how
long it actually takes malloc to "record in some list" what memory has
been allocated. We're benchmarking the book-keeping.

The timing does effectively approaches the time required to perform a
single malloc. Without also involving the time required to call free(),
we are left with effective limits on what allocation ranges will produce
interesting results. Computing CPU-time on OS X using clock() becomes
fruitless once the elapsed allocation time is less than 1/100th of a
second due to (the non-posix) timer resolution. Computing Real time using
gettimeofday() for such short-lived events is also problematic for
different reasons.

> A more interesting test would also write a non-zero byte to each page in the
> allocated region, but that would start to test the performance of malloc +
> the VM system and not just malloc.

That would be an interesting test in and of itself, indeed. On similar
grounds, performance analysis of calloc and/or memset could also prove
interesting.

Cheers!
Sean
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.