[tarantool-patches] Re: [PATCH 1/2] swim: pool IO tasks
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Jul 7 00:00:28 MSK 2019
On 06/07/2019 01:01, Konstantin Osipov wrote:
> * Vladislav Shpilevoy <v.shpilevoy at tarantool.org> [19/07/06 01:39]:
>> +
>> +/**
>> + * All the SWIM instances and their members use the same objects
>> + * to send data - tasks. Each task is ~1.5KB, and on one hand it
>> + * would be a waste of memory to keep preallocated tasks for each
>> + * member. One the other hand it would be too slow to allocate
>> + * and delete ~1.5KB on each interaction, ~3KB on each round step.
>> + * Here is a pool of free tasks shared among all SWIM instances
>> + * to avoid allocations, but do not keep a separate task for each
>> + * member.
>> + */
>> +static struct stailq swim_task_pool;
>> +/** Number of pooled tasks. */
>> +static int swim_task_pool_size = 0;
>
> These should be thread-local.
Why? SWIM works in one thread, these values are never accessed
from another one. They would be just copied for each thread and
unused in all but one.
>
> Why not use mempool?
>
>
Because 1) it is an overkill, 2) I don't want to depend on
slab allocator, 3) it just does not fit this case, according
to mempool description from mempool.h:
"Good for allocating tons of small objects of the same size.".
More information about the Tarantool-patches
mailing list