[systemd-devel] [PATCH] Dynamically allocate bootchart logs

Kok, Auke-jan H auke-jan.h.kok at intel.com
Fri May 3 09:52:31 PDT 2013


On Fri, May 3, 2013 at 9:42 AM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Fri, 03.05.13 09:30, Kok, Auke-jan H (auke-jan.h.kok at intel.com) wrote:
>
>> >> The linked list approach drives down this memory requirement and makes
>> >> navigating all the data much more straightforward. I also much prefer
>> >> head pointers instead of having index numbers around.
>> >
>> > Still sounds like greedy_realloc() is what you want here. Storing sample
>> > data in a dynamically increasing array sounds much more natural than a
>> > linked list.
>>
>> I admit I hadn't heard of greedy_realloc() unti Zbigniew mentioned it,
>> and I still fail to see why it would be so much better other than "you
>> can access members by index". You're still doing an allocation each
>> time you extend the array (unless you're doing tricks and
>> preallocate).
>
> Yes, that's what it does, it reallocates with exponentially increasing
> sizes.
>
> The benefit is random access and a you need two pointers less per entry,
> which is quite something on 64bit...

right, but we don't need random access - all the access is linear, the
extra pointer... doesn't seem like such a gain if we're allocating
hundreds of unused members in the arrays that are going to be unused.

Auke


More information about the systemd-devel mailing list