Performance of the default node allocator.
Dhruv Matani
dhruvbird@gmx.net
Fri Nov 7 17:20:00 GMT 2003
I have here a program that allocates lots of list node, deallocates
them, and then reallocates them. It appears that the default node
allocator fails to preserve the locality or something, and it's
performance is reflected while sorting the list, when the 2nd time is
observered to perform much worse compared to the first (double the
time). I wonder if the allocation starategy of the default node
allocator can be changed? BTW, an allocator calling malloc and free
performs better in terms of preserving order of elements in memory.
--
-Dhruv Matani.
http://www.geocities.com/dhruvbird/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alloc_test.cpp
Type: text/x-c++
Size: 1518 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20031107/51bf6f22/attachment.bin>
-------------- next part --------------
//For malloc/free allocator. Node time for strting list (both times).
[dhruv@home test]$ compile alloc_test.cpp -O3
[dhruv@home test]$ ./alloc_test
Time taken to insert: 0.32 Seconds.
Time taken to sort list: 1.66 Seconds.
Time taken to sort deque: 0.5 Seconds.
Enter a number to continue:3
Time taken to clear list: 0.27 Seconds.
Time taken to clear deque: 0.58 Seconds.
Time taken to insert: 0.27 Seconds.
Time taken to sort list: 1.65 Seconds.
Time taken to sort deque: 0.48 Seconds.
Enter a number to continue:3
Time taken to clear list: 0.27 Seconds.
Time taken to clear deque: 0.58 Seconds.
//For nstd::allocator... Ignore for the moment.
[dhruv@home test]$ compile alloc_test.cpp -O3
[dhruv@home test]$ ./alloc_test
Time taken to insert: 0.27 Seconds.
Time taken to sort list: 1.62 Seconds.
Time taken to sort deque: 0.47 Seconds.
Enter a number to continue:2
Time taken to clear list: 0.21 Seconds.
Time taken to clear deque: 0 Seconds.
Time taken to insert: 0.42 Seconds.
Time taken to sort list: 2.76 Seconds.
Time taken to sort deque: 0.46 Seconds.
Enter a number to continue:3
Time taken to clear list: 0.22 Seconds.
Time taken to clear deque: 0.01 Seconds.
//For std::allocator. See the sorting time for the 2nd time.
[dhruv@home test]$ compile alloc_test.cpp -O3
[dhruv@home test]$ ./alloc_test
Time taken to insert: 0.24 Seconds.
Time taken to sort list: 1.48 Seconds.
Time taken to sort deque: 0.46 Seconds.
Enter a number to continue:3
Time taken to clear list: 0.23 Seconds.
Time taken to clear deque: 0 Seconds.
Time taken to insert: 0.41 Seconds.
Time taken to sort list: 2.56 Seconds.
Time taken to sort deque: 0.44 Seconds.
Enter a number to continue:3
Time taken to clear list: 0.23 Seconds.
Time taken to clear deque: 0.01 Seconds.
More information about the Libstdc++
mailing list