Change default chunk size from 4 MiB to 256 KiB.
Recent changes have improved huge allocation scalability, which removes
upward pressure to set the chunk size so large that huge allocations are
rare. Smaller chunks are more likely to completely drain, so set the
default to the smallest size that doesn't leave excessive unusable
trailing space in chunk headers.
diff --git a/doc/jemalloc.xml.in b/doc/jemalloc.xml.in
index b392fa9..747e03f 100644
--- a/doc/jemalloc.xml.in
+++ b/doc/jemalloc.xml.in
@@ -571,8 +571,8 @@
both large or both huge. In such cases shrinkage always succeeds, but
growth only succeeds if the trailing memory is currently available.</para>
- <para>Assuming 4 MiB chunks, 4 KiB pages, and a 16-byte quantum on a 64-bit
- system, the size classes in each category are as shown in <xref
+ <para>Assuming 256 KiB chunks, 4 KiB pages, and a 16-byte quantum on a
+ 64-bit system, the size classes in each category are as shown in <xref
linkend="size_classes" xrefstyle="template:Table %n"/>.</para>
<table xml:id="size_classes" frame="all">
@@ -627,7 +627,7 @@
<entry>[10 KiB, 12 KiB, 14 KiB]</entry>
</row>
<row>
- <entry morerows="8">Large</entry>
+ <entry morerows="4">Large</entry>
<entry>2 KiB</entry>
<entry>[16 KiB]</entry>
</row>
@@ -645,7 +645,12 @@
</row>
<row>
<entry>32 KiB</entry>
- <entry>[160 KiB, 192 KiB, 224 KiB, 256 KiB]</entry>
+ <entry>[160 KiB, 192 KiB, 224 KiB]</entry>
+ </row>
+ <row>
+ <entry morerows="9">Huge</entry>
+ <entry>32 KiB</entry>
+ <entry>[256 KiB]</entry>
</row>
<row>
<entry>64 KiB</entry>
@@ -653,20 +658,15 @@
</row>
<row>
<entry>128 KiB</entry>
- <entry>[640 KiB, 768 KiB, 896 KiB, 1024 KiB]</entry>
+ <entry>[640 KiB, 768 KiB, 896 KiB, 1 MiB]</entry>
</row>
<row>
<entry>256 KiB</entry>
- <entry>[1280 KiB, 1536 KiB, 1792 KiB, 2048 KiB]</entry>
+ <entry>[1280 KiB, 1536 KiB, 1792 KiB, 2 MiB]</entry>
</row>
<row>
<entry>512 KiB</entry>
- <entry>[2560 KiB, 3072 KiB, 3584 KiB]</entry>
- </row>
- <row>
- <entry morerows="5">Huge</entry>
- <entry>512 KiB</entry>
- <entry>[4 MiB]</entry>
+ <entry>[2560 KiB, 3 MiB, 3584 KiB, 4 MiB]</entry>
</row>
<row>
<entry>1 MiB</entry>
@@ -907,7 +907,7 @@
<listitem><para>Virtual memory chunk size (log base 2). If a chunk
size outside the supported size range is specified, the size is
silently clipped to the minimum/maximum supported size. The default
- chunk size is 4 MiB (2^22).
+ chunk size is 256 KiB (2^18).
</para></listitem>
</varlistentry>
diff --git a/include/jemalloc/internal/chunk.h b/include/jemalloc/internal/chunk.h
index 1a968a5..1af5b24 100644
--- a/include/jemalloc/internal/chunk.h
+++ b/include/jemalloc/internal/chunk.h
@@ -5,7 +5,7 @@
* Size and alignment of memory chunks that are allocated by the OS's virtual
* memory system.
*/
-#define LG_CHUNK_DEFAULT 22
+#define LG_CHUNK_DEFAULT 18
/* Return the chunk address for allocation address a. */
#define CHUNK_ADDR2BASE(a) \