aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-04-08 14:17:57 -0700
committerJason Evans <jasone@canonware.com>2016-10-04 19:48:50 -0700
commitf193fd80cf1f99bce2bc9f5f4a8b149219965da2 (patch)
treec69e648a4f5f5531f63f6badd79e9e14a71fb8a2 /include
parent1abb49f09d98e265ad92a831a056ccdfb4cf6041 (diff)
downloadjemalloc-f193fd80cf1f99bce2bc9f5f4a8b149219965da2.tar.gz
Refactor runs_avail.
Use pszind_t size classes rather than szind_t size classes, and always reserve space for NPSIZES elements. This removes unused heaps that are not multiples of the page size, and adds (currently) unused heaps for all huge size classes, with the immediate benefit that the size of arena_t allocations is constant (no longer dependent on chunk size).
Diffstat (limited to 'include')
-rw-r--r--include/jemalloc/internal/arena.h9
-rw-r--r--include/jemalloc/internal/jemalloc_internal.h.in27
-rw-r--r--include/jemalloc/internal/private_symbols.txt3
3 files changed, 32 insertions, 7 deletions
diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h
index b1de2b6..0600770 100644
--- a/include/jemalloc/internal/arena.h
+++ b/include/jemalloc/internal/arena.h
@@ -470,10 +470,12 @@ struct arena_s {
arena_bin_t bins[NBINS];
/*
- * Quantized address-ordered heaps of this arena's available runs. The
- * heaps are used for first-best-fit run allocation.
+ * Size-segregated address-ordered heaps of this arena's available runs,
+ * used for first-best-fit run allocation. Runs are quantized, i.e.
+ * they reside in the last heap which corresponds to a size class less
+ * than or equal to the run size.
*/
- arena_run_heap_t runs_avail[1]; /* Dynamically sized. */
+ arena_run_heap_t runs_avail[NPSIZES];
};
/* Used in conjunction with tsd for fast arena-related context lookup. */
@@ -505,7 +507,6 @@ extern size_t map_bias; /* Number of arena chunk header pages. */
extern size_t map_misc_offset;
extern size_t arena_maxrun; /* Max run size for arenas. */
extern size_t large_maxclass; /* Max large size class. */
-extern size_t run_quantize_max; /* Max run_quantize_*() input. */
extern unsigned nlclasses; /* Number of large size classes. */
extern unsigned nhclasses; /* Number of huge size classes. */
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
index 76dff3f..9708df9 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -461,10 +461,15 @@ extern unsigned narenas_auto;
extern arena_t **arenas;
/*
+ * pind2sz_tab encodes the same information as could be computed by
+ * pind2sz_compute().
+ */
+extern size_t const pind2sz_tab[NPSIZES];
+/*
* index2size_tab encodes the same information as could be computed (at
* unacceptable cost in some code paths) by index2size_compute().
*/
-extern size_t const index2size_tab[NSIZES+1];
+extern size_t const index2size_tab[NSIZES];
/*
* size2index_tab is a compact lookup table that rounds request sizes up to
* size classes. In order to reduce cache footprint, the table is compressed,
@@ -549,6 +554,8 @@ void jemalloc_postfork_child(void);
#ifndef JEMALLOC_ENABLE_INLINE
pszind_t psz2ind(size_t psz);
+size_t pind2sz_compute(pszind_t pind);
+size_t pind2sz_lookup(pszind_t pind);
size_t pind2sz(pszind_t pind);
size_t psz2u(size_t psz);
szind_t size2index_compute(size_t size);
@@ -596,7 +603,7 @@ psz2ind(size_t psz)
}
JEMALLOC_INLINE size_t
-pind2sz(pszind_t pind)
+pind2sz_compute(pszind_t pind)
{
{
@@ -617,6 +624,22 @@ pind2sz(pszind_t pind)
}
JEMALLOC_INLINE size_t
+pind2sz_lookup(pszind_t pind)
+{
+ size_t ret = (size_t)pind2sz_tab[pind];
+ assert(ret == pind2sz_compute(pind));
+ return (ret);
+}
+
+JEMALLOC_INLINE size_t
+pind2sz(pszind_t pind)
+{
+
+ assert(pind < NPSIZES);
+ return (pind2sz_lookup(pind));
+}
+
+JEMALLOC_INLINE size_t
psz2u(size_t psz)
{
diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt
index a9d6973..c59f82b 100644
--- a/include/jemalloc/internal/private_symbols.txt
+++ b/include/jemalloc/internal/private_symbols.txt
@@ -402,6 +402,8 @@ pages_purge
pages_trim
pages_unmap
pind2sz
+pind2sz_compute
+pind2sz_lookup
pow2_ceil_u32
pow2_ceil_u64
pow2_ceil_zu
@@ -480,7 +482,6 @@ rtree_val_read
rtree_val_write
run_quantize_ceil
run_quantize_floor
-run_quantize_max
s2u
s2u_compute
s2u_lookup