[Tarantool-patches] FW: [PATCH v2 1/3] small: implement new size class evaluation
Evgeny Mekhanik
mechanik20051988 at tarantool.org
Fri Dec 25 10:48:54 MSK 2020
>> I don't understand. So you can make the factor smaller than it was
>> requested? What is the point in configuring the factor then?
> 9. The user configures the allocation factor, the actual factor may differ,
> but it depends directly on the parameter set by the user.
> User can choose the parameter so that it suits the real allocation factor.
But this is not the answer on the question, is it? What is the point is
making it bigger if it can get smaller in the result? And the user can't
even understand how to select the factor he actually needs. For instance,
he sets 1.5, but he has no idea what will be the final value. How can one
tune it then? How to choose the value?
Answer:
This is an approximating function, so it really changes the allocation factor.
We can pass the real factor up and print it so that the user understands the real value
> diff --git a/small/small_class.h b/small/small_class.h
> new file mode 100644
> index 0000000..0677557
> --- /dev/null
> +++ b/small/small_class.h
> @@ -0,0 +1,218 @@
> +
> +/**
> + * CHAR_BIT
> + */
> +#include <limits.h>
> +
> +/**
> + *
Unnecessary empty line.
Fixed: Delete unnecessary empty line.
+/**
+ * CHAR_BIT
+ */
+#include <limits.h>
+
+/**
+ * small_alloc uses a collection of mempools of different sizes.
> + * small_alloc uses a collection of mempools of different sizes.
> + * If small_alloc stores all mempools in an array then it have to determine
> + * an offset in that array where the most suitable mempool is.
> + * Let's name the offset as 'size class' and the size that the corresponding
> + * mempool allocates as 'class size'.> diff --git a/test/small_class.c b/test/small_class.c
> new file mode 100644
> index 0000000..b56cfeb
> --- /dev/null
> +++ b/test/small_class.c
> @@ -0,0 +1,176 @@
> +#include "small/small_class.h"
> +#include "unit.h"
> +#include <math.h>
> +
> +#define SZR(arr) sizeof(arr) / sizeof(arr[0])
We have lengthof() in trivia/util.h.
Answer:
We can't use lengthof() from trivia/util.h, because this file is not a part of small project.
Small should be built by itself without dependencies from third-party components, but
i change my macro SZR to lengthof as you can see in patch below:
+#include "small/small_class.h"
+#include "unit.h"
+#include <math.h>
+
+#ifndef lengthof
+#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))
+#endif
+
+static void
+test_class(void)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20201225/d46c8615/attachment.html>
More information about the Tarantool-patches
mailing list