[tarantool-patches] Re: [PATCH 1/2] swim: pool IO tasks

Konstantin Osipov kostja at tarantool.org
Mon Jul 8 11:25:21 MSK 2019


* Vladislav Shpilevoy <v.shpilevoy at tarantool.org> [19/07/07 16:28]:
> >> +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.

What happens if I create multiple instances of swim library in
multiple threads? These instances will try to concurrently access
these members without mutexes.
> 
> > 
> > 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.".

It is also quite decent for allocating many fairly large objects.
The key point is that the object is of the same size. You can set
up mempool the right slab size, and in this case it will do
exactly what you want.

-- 
Konstantin Osipov, Moscow, Russia




More information about the Tarantool-patches mailing list