Allocator performance testing

Loren James Rittle rittle@latour.rsch.comm.mot.com
Thu Feb 6 02:22:00 GMT 2003


> Measuring performance and comparing different solutions/approaches is as 
> always tricky. However we felt that we needed some _simple_ tools to 
> make sure that the allocator (aimed at MT applications) that we are 
> working on performs as expected.
> [...] NOTE! The numbers from the alloc_perf_comp_mt.cc version includes 
> figures from testing a crude version of our allocator which will result 
> in a patch for review soon - so far it's looking good and there are 
> quite a few things in there addressing other issues that this simple 
> test can't reveal (in terms of long term fragmentation, heap growth etc).

Hi Stefan,

Thank you for posting your performance evaluation code.  Your test
case exposes something known to me for a while: Some malloc()
implementations do internal thread support better than our pool
allocator (inherited from SGI/HP).  For example, FreeBSD uses
spinlocks internally that are much lighter weight than gthread/pthread
mutex API used by our pool allocator.  To display this quirk, I have
attached data for my local system.  I will be happy to review (and
performance test in additional environments) any patch that you submit
in this area.  For a long time, I wanted to investigate how to
properly make a per-platform choice as to the best default allocator
(perhaps additionally keyed off state of threading support as detected
by the gthread layer).  Especially, if you want to propose a change of
the library default, we will need to look at performance across many
platforms in addition to test case selection.

Regards,
Loren

(FYI, I had a fairly consistent background load during this test.  I
can't test -static -pthread since not compatible on this platform.)

single PII/350Mhz (i386-unknown-freebsd4.7);
gcc version 3.4 20030204 (experimental):

g++ -O2 st.C
Target run-time: 10s
Calibrating test_ints... DONE! Will do 1600000 iterations.
__pool_alloc... DONE! Time 18.184488
__malloc_alloc... DONE! Time 40.728027
Relative performance to __pool_alloc:
__malloc_alloc 44.648586 %

g++ -O2 -pthread st.C # force use of gthread mutex even though single-threaded
Target run-time: 10s
Calibrating test_ints... DONE! Will do 200000 iterations.
__pool_alloc... DONE! Time 9.901432
__malloc_alloc... DONE! Time 3.251480
Relative performance to __pool_alloc:
__malloc_alloc 304.520775 %

g++ -O2 -pthread mt.C
Target run-time: 10s
Calibrating test_ints... DONE! Will do 200000 iterations.
__pool_alloc... DONE! Time 294.534824
__malloc_alloc... DONE! Time 41.198546
Relative performance to __pool_alloc:
__malloc_alloc 714.915579 %



More information about the Libstdc++ mailing list