[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: QUESTION: obstack, size of new chunk?
From: |
Hans Aberg |
Subject: |
Re: QUESTION: obstack, size of new chunk? |
Date: |
Sun, 4 Jan 2015 14:45:00 +0100 |
On 3 Jan 2015, at 21:15, Sean Nakasone <address@hidden> wrote:
>
> Hi, lib/obstack.c has a function, _obstack_newchunk().
>
> there's a formula used to calculate a variable new_size
>
> new_size = (obj_size + length) + (obj_size >> 3) + h->alignment_mask + 100;
>
> i understand obj_size + length, but what's the other stuff for?
Perhaps some reallocation policy, avoiding too many reallocations. On a C++
class std::vector, one might double the allocations, and half if it gets down
below a quarter: some hysteresis, to avoid border cases producing a lot of
reallocations.