mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 15:29:31 +03:00
optimize page struct layout
This commit is contained in:
parent
af3f2f9168
commit
7c17c3d33e
2 changed files with 7 additions and 6 deletions
|
@ -292,14 +292,15 @@ typedef struct mi_page_s {
|
||||||
// layout like this to optimize access in `mi_malloc` and `mi_free`
|
// layout like this to optimize access in `mi_malloc` and `mi_free`
|
||||||
uint16_t capacity; // number of blocks committed, must be the first field, see `segment.c:page_clear`
|
uint16_t capacity; // number of blocks committed, must be the first field, see `segment.c:page_clear`
|
||||||
uint16_t reserved; // number of blocks reserved in memory
|
uint16_t reserved; // number of blocks reserved in memory
|
||||||
uint16_t used; // number of blocks in use (including blocks in `thread_free`)
|
|
||||||
mi_page_flags_t flags; // `in_full` and `has_aligned` flags (8 bits)
|
mi_page_flags_t flags; // `in_full` and `has_aligned` flags (8 bits)
|
||||||
uint8_t block_size_shift; // if not zero, then `(1 << block_size_shift) == block_size` (only used for fast path in `free.c:_mi_page_ptr_unalign`)
|
|
||||||
uint8_t free_is_zero:1; // `true` if the blocks in the free list are zero initialized
|
uint8_t free_is_zero:1; // `true` if the blocks in the free list are zero initialized
|
||||||
uint8_t retire_expire:7; // expiration count for retired blocks
|
uint8_t retire_expire:7; // expiration count for retired blocks
|
||||||
// padding
|
|
||||||
mi_block_t* free; // list of available free blocks (`malloc` allocates from this list)
|
mi_block_t* free; // list of available free blocks (`malloc` allocates from this list)
|
||||||
mi_block_t* local_free; // list of deferred free blocks by this thread (migrates to `free`)
|
mi_block_t* local_free; // list of deferred free blocks by this thread (migrates to `free`)
|
||||||
|
uint16_t used; // number of blocks in use (including blocks in `thread_free`)
|
||||||
|
uint8_t block_size_shift; // if not zero, then `(1 << block_size_shift) == block_size` (only used for fast path in `free.c:_mi_page_ptr_unalign`)
|
||||||
|
// padding
|
||||||
size_t block_size; // size available in each block (always `>0`)
|
size_t block_size; // size available in each block (always `>0`)
|
||||||
uint8_t* page_start; // start of the page area containing the blocks
|
uint8_t* page_start; // start of the page area containing the blocks
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,17 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
|
|
||||||
// Empty page used to initialize the small free pages array
|
// Empty page used to initialize the small free pages array
|
||||||
const mi_page_t _mi_page_empty = {
|
const mi_page_t _mi_page_empty = {
|
||||||
0,
|
0,
|
||||||
false, false, false, false,
|
false, false, false, false,
|
||||||
0, // capacity
|
0, // capacity
|
||||||
0, // reserved capacity
|
0, // reserved capacity
|
||||||
0, // used
|
|
||||||
{ 0 }, // flags
|
{ 0 }, // flags
|
||||||
0, // block size shift
|
|
||||||
false, // is_zero
|
false, // is_zero
|
||||||
0, // retire_expire
|
0, // retire_expire
|
||||||
NULL, // free
|
NULL, // free
|
||||||
NULL, // local_free
|
NULL, // local_free
|
||||||
|
0, // used
|
||||||
|
0, // block size shift
|
||||||
0, // block_size
|
0, // block_size
|
||||||
NULL, // page_start
|
NULL, // page_start
|
||||||
#if (MI_PADDING || MI_ENCODE_FREELIST)
|
#if (MI_PADDING || MI_ENCODE_FREELIST)
|
||||||
|
|
Loading…
Add table
Reference in a new issue