[Tarantool-patches] [PATCH small 0/2] Aligned lsregion

Aleksandr Lyapunov alyapunov at tarantool.org
Fri May 15 15:26:15 MSK 2020


Thanks for the patch! see comments below.

On 5/15/20 2:31 AM, Vladislav Shpilevoy wrote:
> The patchset introduces a new function - lsregion_aligned_alloc().

Actually you don't need the patch for fixing #4609.
If you want to align vy_mem tuple by 4 bytes (due to uint32_t bsize), 
all you need is:

diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c
index adc3ba4..2de4a28 100644
--- a/src/box/vy_stmt.c
+++ b/src/box/vy_stmt.c
@@ -228,7 +228,7 @@ vy_stmt_dup_lsregion(struct tuple *stmt, struct 
lsregion *lsregion,
         if (type == IPROTO_UPSERT)
                 alloc_size++;

-       mem_stmt = lsregion_alloc(lsregion, alloc_size, alloc_id);
+       mem_stmt = lsregion_alloc(lsregion, small_align(alloc_size, 4), 
alloc_id);
         if (mem_stmt == NULL) {
                 diag_set(OutOfMemory, size, "lsregion_alloc", "mem_stmt");
                 return NULL;

lsregion will allocate aligned addresses as long as you request only 
aligned sizes,
up to sizeof(uintptr_t) (see lslab_sizeof()).
This property is not documented (maybe it should be!). It is also 
similar to mempool
property, see mempool_create description.

I like one-line change more.

If you still want _reserve and _aligned_alloc method for further 
purposes, please
read my by-commit comments.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20200515/ccfb3bba/attachment.html>


More information about the Tarantool-patches mailing list