vinyl: align statements and bps tree extents
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 is 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
Showing
- src/box/vy_mem.c 5 additions, 4 deletionssrc/box/vy_mem.c
- src/box/vy_stmt.c 8 additions, 5 deletionssrc/box/vy_stmt.c
- test/vinyl/quota.result 5 additions, 5 deletionstest/vinyl/quota.result
- test/vinyl/quota_timeout.result 2 additions, 2 deletionstest/vinyl/quota_timeout.result
- test/vinyl/stat.result 2 additions, 2 deletionstest/vinyl/stat.result
Loading
Please register or sign in to comment