mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 07:29:30 +03:00
Merge branch 'dev' into dev-win
This commit is contained in:
commit
b005f7cdbf
2 changed files with 18 additions and 10 deletions
|
@ -394,7 +394,7 @@ void _mi_page_retire(mi_page_t* page) {
|
||||||
// is the only page left with free blocks. It is not clear
|
// is the only page left with free blocks. It is not clear
|
||||||
// how to check this efficiently though... for now we just check
|
// how to check this efficiently though... for now we just check
|
||||||
// if its neighbours are almost fully used.
|
// if its neighbours are almost fully used.
|
||||||
if (mi_likely(page->block_size <= MI_MEDIUM_OBJ_SIZE_MAX)) {
|
if (mi_likely(page->block_size <= MI_SMALL_SIZE_MAX)) {
|
||||||
if (mi_page_mostly_used(page->prev) && mi_page_mostly_used(page->next)) {
|
if (mi_page_mostly_used(page->prev) && mi_page_mostly_used(page->next)) {
|
||||||
_mi_stat_counter_increase(&_mi_stats_main.page_no_retire,1);
|
_mi_stat_counter_increase(&_mi_stats_main.page_no_retire,1);
|
||||||
return; // dont't retire after all
|
return; // dont't retire after all
|
||||||
|
|
16
src/stats.c
16
src/stats.c
|
@ -28,11 +28,14 @@ void _mi_stats_done(mi_stats_t* stats) {
|
||||||
Statistics operations
|
Statistics operations
|
||||||
----------------------------------------------------------- */
|
----------------------------------------------------------- */
|
||||||
|
|
||||||
|
static bool mi_is_in_main(void* stat) {
|
||||||
|
return ((uint8_t*)stat >= (uint8_t*)&_mi_stats_main
|
||||||
|
&& (uint8_t*)stat < ((uint8_t*)&_mi_stats_main + sizeof(mi_stats_t)));
|
||||||
|
}
|
||||||
|
|
||||||
static void mi_stat_update(mi_stat_count_t* stat, int64_t amount) {
|
static void mi_stat_update(mi_stat_count_t* stat, int64_t amount) {
|
||||||
if (amount == 0) return;
|
if (amount == 0) return;
|
||||||
bool in_main = ((uint8_t*)stat >= (uint8_t*)&_mi_stats_main
|
if (mi_is_in_main(stat))
|
||||||
&& (uint8_t*)stat < ((uint8_t*)&_mi_stats_main + sizeof(mi_stats_t)));
|
|
||||||
if (in_main)
|
|
||||||
{
|
{
|
||||||
// add atomically (for abandoned pages)
|
// add atomically (for abandoned pages)
|
||||||
int64_t current = mi_atomic_add(&stat->current,amount);
|
int64_t current = mi_atomic_add(&stat->current,amount);
|
||||||
|
@ -58,11 +61,16 @@ static void mi_stat_update(mi_stat_count_t* stat, int64_t amount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _mi_stat_counter_increase(mi_stat_counter_t* stat, size_t amount) {
|
void _mi_stat_counter_increase(mi_stat_counter_t* stat, size_t amount) {
|
||||||
|
if (mi_is_in_main(stat)) {
|
||||||
mi_atomic_add( &stat->count, 1 );
|
mi_atomic_add( &stat->count, 1 );
|
||||||
mi_atomic_add( &stat->total, (int64_t)amount );
|
mi_atomic_add( &stat->total, (int64_t)amount );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stat->count++;
|
||||||
|
stat->total += amount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _mi_stat_increase(mi_stat_count_t* stat, size_t amount) {
|
void _mi_stat_increase(mi_stat_count_t* stat, size_t amount) {
|
||||||
mi_stat_update(stat, (int64_t)amount);
|
mi_stat_update(stat, (int64_t)amount);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue