summaryrefslogtreecommitdiffstats
path: root/include/jemalloc
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-03-24 06:45:11 (GMT)
committerJason Evans <jasone@canonware.com>2017-03-25 00:52:46 (GMT)
commit5d33233a5e6601902df7cddd8cc8aa0b135c77b2 (patch)
treef63679e2d31a0aade6c8aa5c47928f7ec68543d8 /include/jemalloc
parent57e353163f0ec099aed8feee2083e95c9d4b472b (diff)
downloadjemalloc-5d33233a5e6601902df7cddd8cc8aa0b135c77b2.zip
jemalloc-5d33233a5e6601902df7cddd8cc8aa0b135c77b2.tar.gz
jemalloc-5d33233a5e6601902df7cddd8cc8aa0b135c77b2.tar.bz2
Use a bitmap in extents_t to speed up search.
Rather than iteratively checking all sufficiently large heaps during search, maintain and use a bitmap in order to skip empty heaps.
Diffstat (limited to 'include/jemalloc')
-rw-r--r--include/jemalloc/internal/bitmap_types.h8
-rw-r--r--include/jemalloc/internal/extent_structs.h7
2 files changed, 14 insertions, 1 deletions
diff --git a/include/jemalloc/internal/bitmap_types.h b/include/jemalloc/internal/bitmap_types.h
index d0de2f0..b334769 100644
--- a/include/jemalloc/internal/bitmap_types.h
+++ b/include/jemalloc/internal/bitmap_types.h
@@ -2,7 +2,13 @@
#define JEMALLOC_INTERNAL_BITMAP_TYPES_H
/* Maximum bitmap bit count is 2^LG_BITMAP_MAXBITS. */
-#define LG_BITMAP_MAXBITS LG_SLAB_MAXREGS
+#if LG_SLAB_MAXREGS > LG_CEIL_NSIZES
+/* Maximum bitmap bit count is determined by maximum regions per slab. */
+# define LG_BITMAP_MAXBITS LG_SLAB_MAXREGS
+#else
+/* Maximum bitmap bit count is determined by number of extent size classes. */
+# define LG_BITMAP_MAXBITS LG_CEIL_NSIZES
+#endif
#define BITMAP_MAXBITS (ZU(1) << LG_BITMAP_MAXBITS)
typedef struct bitmap_level_s bitmap_level_t;
diff --git a/include/jemalloc/internal/extent_structs.h b/include/jemalloc/internal/extent_structs.h
index 82cfa58..5cf3c9b 100644
--- a/include/jemalloc/internal/extent_structs.h
+++ b/include/jemalloc/internal/extent_structs.h
@@ -103,6 +103,13 @@ struct extents_s {
extent_heap_t heaps[NPSIZES+1];
/*
+ * Bitmap for which set bits correspond to non-empty heaps.
+ *
+ * Synchronization: mtx.
+ */
+ bitmap_t bitmap[BITMAP_GROUPS(NPSIZES+1)];
+
+ /*
* LRU of all extents in heaps.
*
* Synchronization: mtx.