This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Fwd: basic_string<> - useless because of its poor performance]

Loren James Rittle <> 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   `------------------------

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]