Skip to content
Snippets Groups Projects
Commit fcfa6bcf authored by mechanik20051988's avatar mechanik20051988 Committed by Nikita Pettik
Browse files

memtx: fix memory allocation errors for distributed size tuples

Changed small allocator strategy. In previous version small allocate
memory from the most appropriate pool. This strategy has one significant
disadvantage: during memory allocation for tuples with highly distributed
sizes, we allocate an entire whole slab for one or two objects, moreover,
when they are further deleted, slab is not released (see spare slab in
mempool). Now we divide mempools with the same slab size into groups
containing no more than 32 pools. First, we allocate memory from mempool
with the largest size in group, then when memory waste for a certain size
of objects as a result of a non-optimal pool selection became larger then
slab size / 4, we start allocating memory for them from the most suitable
mempool. At the same time, for other objects, we can use both of these
mempools, in case if new mempool has a larger objsize. With this strategy,
we avoid losing memory.
Also change allocator behaviour in the matter of saving spare slab. With new
allocator strategy we don't need to save spare slab for all mempools, we need
to save it only for the last mempool in group. This strategy solves both
problems - there is no unnecessary memory loss on the spare slabs and we
prevent oscillations when single object is repeatedly allocated.

Closes #3633
parent 7dfad83f
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment