summaryrefslogtreecommitdiff
path: root/include/mimalloc-types.h
diff options
context:
space:
mode:
authordaan <daanl@outlook.com>2021-11-13 14:03:16 -0800
committerdaan <daanl@outlook.com>2021-11-13 14:03:16 -0800
commit9afc253726fbe28015b3c37841e41c9202d382ef (patch)
tree0dc0267e14fbf161b8508f3b3d24fc3c5de1c676 /include/mimalloc-types.h
parent8bf16746e9b832972c76eef74165b0a782dce2c1 (diff)
add comments, renaming
Diffstat (limited to 'include/mimalloc-types.h')
-rw-r--r--include/mimalloc-types.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/include/mimalloc-types.h b/include/mimalloc-types.h
index c60457c..5bf779f 100644
--- a/include/mimalloc-types.h
+++ b/include/mimalloc-types.h
@@ -287,17 +287,26 @@ typedef enum mi_segment_kind_e {
MI_SEGMENT_HUGE, // > MI_LARGE_SIZE_MAX segment with just one huge page inside.
} mi_segment_kind_t;
-#define MI_COMMIT_SIZE (4*64*1024)
-#define MI_COMMIT_MASK_BITS (MI_SEGMENT_SIZE / MI_COMMIT_SIZE)
-#define MI_COMMIT_MASK_FIELD_BITS MI_SIZE_BITS
-#define MI_COMMIT_MASK_N (MI_COMMIT_MASK_BITS / MI_COMMIT_MASK_FIELD_BITS)
+// ------------------------------------------------------
+// A segment holds a commit mask where a bit is set if
+// the corresponding MI_COMMIT_SIZE area is committed.
+// The MI_COMMIT_SIZE must be a multiple of the slice
+// size. We define it as equal so we can decommit on a
+// slice level which helps with (real) memory fragmentation
+// over time.
+// ------------------------------------------------------
+
+#define MI_COMMIT_SIZE (MI_SEGMENT_SLICE_SIZE)
+#define MI_COMMIT_MASK_BITS (MI_SEGMENT_SIZE / MI_COMMIT_SIZE)
+#define MI_COMMIT_MASK_FIELD_BITS MI_SIZE_BITS
+#define MI_COMMIT_MASK_FIELD_COUNT (MI_COMMIT_MASK_BITS / MI_COMMIT_MASK_FIELD_BITS)
-#if (MI_COMMIT_MASK_BITS != (MI_COMMIT_MASK_N * MI_COMMIT_MASK_FIELD_BITS))
+#if (MI_COMMIT_MASK_BITS != (MI_COMMIT_MASK_FIELD_COUNT * MI_COMMIT_MASK_FIELD_BITS))
#error "the segment size must be exactly divisible by the (commit size * size_t bits)"
#endif
typedef struct mi_commit_mask_s {
- size_t mask[MI_COMMIT_MASK_N];
+ size_t mask[MI_COMMIT_MASK_FIELD_COUNT];
} mi_commit_mask_t;
typedef mi_page_t mi_slice_t;