[Tarantool-patches] [PATCH 07/10] vinyl: align statements and bps tree extents
Cyrill Gorcunov
gorcunov at gmail.com
Mon Jun 8 17:02:26 MSK 2020
On Thu, May 21, 2020 at 10:37:30PM +0200, Vladislav Shpilevoy wrote:
> Vinyl tuples (vy_stmt) in 0 level of LSM tree are stored in
> lsregion. They were allocated using lsregion_alloc(), which does
> not align its results, and is good only for byte arrays.
>
> As a result, vy_stmt object addresses in 0 LSM level were not
> aligned. Unaligned memory access is slower, and may even crash on
> some platforms.
>
> Besides, even aligned allocations couldn't help upserts in 0 level
> of the LSM tree, because upsert vy_stmt objects had 1 byte prefix
> to count merged upserts stored in this statement. This 1 byte
> prefix ruined all the alignment. Now the upsert counter is also
> aligned, the same as vy_stmt. Note, it does not consume
> significantly more memory, since it used only for vinyl and only
> for upserts, stored in 0 level of the LSM tree.
>
> The same about BPS tree extents. LSM 0 level is a BPS tree, whose
> blocks are allocated on lsregion. The extents are used as pointer
> arrays inside the tree, so they need alignof(void *) alignment.
>
> The mentioned unaligned accesses were revealed by clang undefined
> behaviour sanitizer, and are fixed by this patch.
>
> Part of #4609
Reviewed-by: Cyrill Gorcunov <gorcunov at gmail.com>
More information about the Tarantool-patches
mailing list