mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 23:39:31 +03:00
add comment on wait strategy in region allocation
This commit is contained in:
parent
f5902a7a82
commit
6435887657
1 changed files with 7 additions and 1 deletions
|
@ -139,7 +139,13 @@ static bool mi_region_commit_blocks(mem_region_t* region, size_t idx, size_t bit
|
||||||
start = ALLOCATING; // try to start allocating
|
start = ALLOCATING; // try to start allocating
|
||||||
}
|
}
|
||||||
else if (start == ALLOCATING) {
|
else if (start == ALLOCATING) {
|
||||||
mi_atomic_yield(); // another thead is already allocating.. wait it out
|
// another thead is already allocating.. wait it out
|
||||||
|
// note: the wait here is not great (but should not happen often). Another
|
||||||
|
// strategy might be to just allocate another region in parallel. This tends
|
||||||
|
// to be bad for benchmarks though as these often start many threads at the
|
||||||
|
// same time leading to the allocation of too many regions. (Still, this might
|
||||||
|
// be the most performant and it's ok on 64-bit virtual memory with over-commit.)
|
||||||
|
mi_atomic_yield();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} while( start == ALLOCATING && !mi_atomic_compare_exchange_ptr(®ion->start, ALLOCATING, NULL) );
|
} while( start == ALLOCATING && !mi_atomic_compare_exchange_ptr(®ion->start, ALLOCATING, NULL) );
|
||||||
|
|
Loading…
Add table
Reference in a new issue