Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH small 1/1] test: don't use not aligned size for mempool
@ 2020-06-20 18:01 Vladislav Shpilevoy
  2020-06-21 10:06 ` Sergey Ostanevich
  0 siblings, 1 reply; 3+ messages in thread
From: Vladislav Shpilevoy @ 2020-06-20 18:01 UTC (permalink / raw)
  To: tarantool-patches, avtikhon, kyukhin

Mempool expects aligned object size. Because it uses the free
blocks to store metadata in them, in a struct mslab. Which needs
alignment.

Part of https://github.com/tarantool/tarantool/issues/5063
---
Branch: http://github.com/tarantool/small/tree/gerold103/tarantool/gh-5063-not-aligned-test
Issue: https://github.com/tarantool/tarantool/issues/5063

 test/mempool.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/mempool.c b/test/mempool.c
index 298ba17..65eabaf 100644
--- a/test/mempool.c
+++ b/test/mempool.c
@@ -1,3 +1,4 @@
+#include "trivia/util.h"
 #include <small/mempool.h>
 #include <small/quota.h>
 #include <stdio.h>
@@ -121,6 +122,12 @@ int main()
 	objsize = rand() % OBJSIZE_MAX;
 	if (objsize < OBJSIZE_MIN)
 		objsize = OBJSIZE_MIN;
+	/*
+	 * Mempool does not work with not aligned sizes. Because
+	 * it utilizes the unused blocks for storing internal
+	 * info, which needs alignment.
+	 */
+	objsize = small_align(objsize, alignof(uint64_t));
 
 	quota_init(&quota, UINT_MAX);
 
-- 
2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH small 1/1] test: don't use not aligned size for mempool
  2020-06-20 18:01 [Tarantool-patches] [PATCH small 1/1] test: don't use not aligned size for mempool Vladislav Shpilevoy
@ 2020-06-21 10:06 ` Sergey Ostanevich
  2020-06-21 15:35   ` Vladislav Shpilevoy
  0 siblings, 1 reply; 3+ messages in thread
From: Sergey Ostanevich @ 2020-06-21 10:06 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]


LGTM.

I wonder how big is impact of all alignment activities? Can you consult with Mons to obtain a reference test?

Best regards,
Sergos 

Saturday, 20 June 2020, 21:01 +0300 from Vladislav Shpilevoy  <v.shpilevoy@tarantool.org>:
>Mempool expects aligned object size. Because it uses the free
>blocks to store metadata in them, in a struct mslab. Which needs
>alignment.
>
>Part of  https://github.com/tarantool/tarantool/issues/5063
>---
>Branch:  http://github.com/tarantool/small/tree/gerold103/tarantool/gh-5063-not-aligned-test
>Issue:  https://github.com/tarantool/tarantool/issues/5063
>
> test/mempool.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
>diff --git a/test/mempool.c b/test/mempool.c
>index 298ba17..65eabaf 100644
>--- a/test/mempool.c
>+++ b/test/mempool.c
>@@ -1,3 +1,4 @@
>+#include "trivia/util.h"
> #include <small/mempool.h>
> #include <small/quota.h>
> #include <stdio.h>
>@@ -121,6 +122,12 @@ int main()
> 	objsize = rand() % OBJSIZE_MAX;
> 	if (objsize < OBJSIZE_MIN)
> 		objsize = OBJSIZE_MIN;
>+	/*
>+	 * Mempool does not work with not aligned sizes. Because
>+	 * it utilizes the unused blocks for storing internal
>+	 * info, which needs alignment.
>+	 */
>+	objsize = small_align(objsize, alignof(uint64_t));
> 
> 	quota_init(&quota, UINT_MAX);
> 
>-- 
>2.21.1 (Apple Git-122.3)
>

[-- Attachment #2: Type: text/html, Size: 4213 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH small 1/1] test: don't use not aligned size for mempool
  2020-06-21 10:06 ` Sergey Ostanevich
@ 2020-06-21 15:35   ` Vladislav Shpilevoy
  0 siblings, 0 replies; 3+ messages in thread
From: Vladislav Shpilevoy @ 2020-06-21 15:35 UTC (permalink / raw)
  To: Sergey Ostanevich; +Cc: tarantool-patches

On 21/06/2020 12:06, Sergey Ostanevich wrote:
> LGTM.
> 
> I wonder how big is impact of all alignment activities? Can you consult with Mons to obtain a reference test?

I am not sure I understand. What has Mons to do with that?

Talking of impact - I suspect it is 0. With the only difference
that formally we don't have unaligned access UB anymore. And
that alongside some real bugs were fixed.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-21 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 18:01 [Tarantool-patches] [PATCH small 1/1] test: don't use not aligned size for mempool Vladislav Shpilevoy
2020-06-21 10:06 ` Sergey Ostanevich
2020-06-21 15:35   ` Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox