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
Showing
- src/lib/small 1 addition, 1 deletionsrc/lib/small
- test/box/errinj.result 1 addition, 1 deletiontest/box/errinj.result
- test/box/errinj.test.lua 1 addition, 1 deletiontest/box/errinj.test.lua
- test/box/gh-3633-simple-tuple-size-increasing.lua 10 additions, 0 deletionstest/box/gh-3633-simple-tuple-size-increasing.lua
- test/box/gh-3633-simple-tuple-size-increasing.result 98 additions, 0 deletionstest/box/gh-3633-simple-tuple-size-increasing.result
- test/box/gh-3633-simple-tuple-size-increasing.test.lua 45 additions, 0 deletionstest/box/gh-3633-simple-tuple-size-increasing.test.lua
- test/box/gh-3633-tuple-size-increasing.result 98 additions, 0 deletionstest/box/gh-3633-tuple-size-increasing.result
- test/box/gh-3633-tuple-size-increasing.test.lua 41 additions, 0 deletionstest/box/gh-3633-tuple-size-increasing.test.lua
- test/box/reconfigure.result 4 additions, 4 deletionstest/box/reconfigure.result
- test/box/reconfigure.test.lua 1 addition, 1 deletiontest/box/reconfigure.test.lua
Loading
Please register or sign in to comment