This is the mail archive of the
mailing list for the libstdc++ project.
Re: [Fwd: basic_string<> - useless because of its poor performance]
- To: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- Subject: Re: [Fwd: basic_string<> - useless because of its poor performance]
- From: Ulrich Drepper <drepper at redhat dot com>
- Date: 05 Jul 2001 15:21:46 -0700
- Cc: libstdc++ at gcc dot gnu dot org, Ryszard dot Kabatek at softax dot pl
- References: <200107052215.f65MFXg63071@latour.rsch.comm.mot.com>
- Reply-To: drepper at cygnus dot com (Ulrich Drepper)
Loren James Rittle <email@example.com> writes:
> First of all, since the C++ library is allocating memory for strings
> using the standard malloc() interface, it should consider always
> starting and growing the allocation by pagesize instead of 1 after
> it may no longer use the fast allocator.
Wrong. Allocating pagesize bytes causes enormous fragmentation. All
allocators get memory in pagesize quantities from the OS. Then they
add there overhead, and the rest they provide to the user. I.e., an
implementation which adds to pointers for administration would have
pagesize+2*sizeof(void*) chunks which does not fit well in multiples
of pagesize bytes.
Always allocate pagesize-N*sizeof(void). Normally N==2 is OK, to be
absolute safe go with N==4. This is a tuning parameter.
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------