We were discussing some hashtable stuff in OOo recently, part of the outcome was...
--- From: Herbert Duerr <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Optimization for empty hashtables Date: Fri, 25 Aug 2006 11:15:50 +0200 (10:15 IST) While analyzing the performance of OpenOffice.org's startup Michael Meeks noticed that a lot of memory is wasted for default constructed hash_map/hash_set etc. objects. Many of these objects remain empty for a considerable time. Even when the hashtable constructor gets a size hint of zero the current implementation will allocate 53 buckets. Since for insertions the bucket count is checked later anyway it is possible to delay this allocation without any performance penalty. Here is a patch against today's trunk that makes initializations of hashtables much cheaper if an "empty" hint is provided. --- The gcc stl implementation is similiar enough, that the following patch may be advantageous -- Summary: hashtable.h initialize reserves a lot of memory, defer until needed Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: caolanm at redhat dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28844