adding size class for 24 bytes pool on x86

Oran Agra oran at redislabs.com
Wed Dec 24 01:35:25 PST 2014


Hi,
I have an application running on x86 that uses jemalloc which can greatly
benefit from an allocation pool of 24 bytes.
currently there are pools for 8,16,32...
I've tried changing include/jemalloc/internal/size_classes.sh with the
following patch:
------------------------------------------------------------
----------------------
-# The range of tiny size classes is [2^lg_tmin..2^(lg_q-1)].
+# The range of tiny size classes is [2^lg_tmin..2^(lg_q+1)].
 lg_tmin=3

 # Range of page sizes.
@@ -48,11 +48,11 @@
       echo "#define    SIZE_CLASSES                            \\"

       # Tiny size classes.
-      while [ ${sz} -lt ${q} ] ; do
+      while [ ${sz} -lt $((${q}*2)) ] ; do
         echo "    SIZE_CLASS(${bin},    ${delta},    ${sz})
    \\"
         bin=$((${bin} + 1))
         psz=${sz}
-        sz=$((${sz} + ${sz}))
+        sz=$((${sz} + ${t}))
         delta=$((${sz} - ${psz}))
       done
------------------------------------------------------------
----------------------

now, my size classes table looks like this:
------------------------------------------------------------
----------------------
/*  SIZE_CLASS(bin,    delta,    sz) */
#define    SIZE_CLASSES                            \
    SIZE_CLASS(0,    8,    8)                    \
    SIZE_CLASS(1,    8,    16)                    \
    SIZE_CLASS(2,    8,    24)                    \
    SIZE_CLASS(3,    8,    32)                    \
    SIZE_CLASS(4,    16,    48)                    \
    SIZE_CLASS(5,    16,    64)                    \
------------------------------------------------------------
----------------------
it seems to work fine, but i'm not sure if there are some side-effects.
the 32 bytes pool which had delta of 16, now has a delta of 8.
i see in the implementation of the SIZE_CLASS macro, that the 'sz' argument
isn't used at all, and the delta argument is.

another approach might be to change LG_QUANTUM to 3 rather than 4.
i think this will create several new small size classes, but may also have
undesired side-effects.

can you please tell me if i got it right? what are the side-effects? or
what is the right way to achieve what I'm trying to do?
thanks.
    Oran.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jemalloc.net/mailman/jemalloc-discuss/attachments/20141224/6d2a08cc/attachment.html>


More information about the jemalloc-discuss mailing list