This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 06/25] Add struct scratch_buffer and its internal helper functions


On Fri, Mar 20, 2015 at 04:08:39PM +0100, Florian Weimer wrote:
> 
> >> +  size_t new_length = buffer->length * 2;
> > 
> > In Gnulib we originally did it this way, but nowadays we grow by a
> > factor of 1.5 (new_length = old_length + old_length / 2 + 1) rather than
> > by a factor of 2, as this was less jerky for large buffers. Perhaps do
> > something similar here?
> 
> I think we should leave the fine-tuning to a later stage.  See also the
> comment above about malloc_usable_size.
> 
> The original code used a growth factor of 3 during the alloca phase, and
> 2 during the malloc phase.  (After the i386 ABI change for stack
> alignment, it's effectively 2 and 2.)
> 
That does not make much sense. Its mostly used in funcions that cannot
realloc array themself so we double space until it fits. As its
temporary its better to overallocate than try save space.

You could use factor 16 to improve performance. If large buffers are
concern then add treshold after which you use 1.5 but I doubt that you
reach 1MB with functions used.


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