mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 23:39:31 +03:00
Merge branch 'dev' into dev3
This commit is contained in:
commit
21c05019b7
6 changed files with 49 additions and 11 deletions
|
@ -43,7 +43,7 @@ jobs:
|
|||
solution: $(BuildType)/libmimalloc.sln
|
||||
configuration: '$(MSBuildConfiguration)'
|
||||
msbuildArguments: -m
|
||||
- script: ctest --verbose --timeout 180 -C $(MSBuildConfiguration)
|
||||
- script: ctest --verbose --timeout 240 -C $(MSBuildConfiguration)
|
||||
workingDirectory: $(BuildType)
|
||||
displayName: CTest
|
||||
#- script: $(BuildType)\$(BuildType)\mimalloc-test-stress
|
||||
|
@ -126,7 +126,7 @@ jobs:
|
|||
cmakeArgs: .. $(cmakeExtraArgs)
|
||||
- script: make -j$(nproc) -C $(BuildType)
|
||||
displayName: Make
|
||||
- script: ctest --verbose --timeout 180
|
||||
- script: ctest --verbose --timeout 240
|
||||
workingDirectory: $(BuildType)
|
||||
displayName: CTest
|
||||
env:
|
||||
|
@ -157,7 +157,7 @@ jobs:
|
|||
cmakeArgs: .. $(cmakeExtraArgs)
|
||||
- script: make -j$(sysctl -n hw.ncpu) -C $(BuildType)
|
||||
displayName: Make
|
||||
- script: ctest --verbose --timeout 180
|
||||
- script: ctest --verbose --timeout 240
|
||||
workingDirectory: $(BuildType)
|
||||
displayName: CTest
|
||||
# - upload: $(Build.SourcesDirectory)/$(BuildType)
|
||||
|
@ -192,7 +192,7 @@ jobs:
|
|||
solution: $(BuildType)/libmimalloc.sln
|
||||
configuration: '$(MSBuildConfiguration)'
|
||||
msbuildArguments: -m
|
||||
- script: ctest --verbose --timeout 180 -C $(MSBuildConfiguration)
|
||||
- script: ctest --verbose --timeout 240 -C $(MSBuildConfiguration)
|
||||
workingDirectory: $(BuildType)
|
||||
displayName: CTest
|
||||
|
||||
|
@ -235,7 +235,7 @@ jobs:
|
|||
cmakeArgs: .. $(cmakeExtraArgs)
|
||||
- script: make -j$(nproc) -C $(BuildType)
|
||||
displayName: Make
|
||||
- script: ctest --verbose --timeout 180
|
||||
- script: ctest --verbose --timeout 240
|
||||
workingDirectory: $(BuildType)
|
||||
displayName: CTest
|
||||
|
||||
|
@ -278,7 +278,7 @@ jobs:
|
|||
cmakeArgs: .. $(cmakeExtraArgs)
|
||||
- script: make -j$(nproc) -C $(BuildType)
|
||||
displayName: Make
|
||||
- script: ctest --verbose --timeout 180
|
||||
- script: ctest --verbose --timeout 240
|
||||
workingDirectory: $(BuildType)
|
||||
displayName: CTest
|
||||
|
||||
|
@ -302,7 +302,7 @@ jobs:
|
|||
cmakeArgs: .. $(cmakeExtraArgs)
|
||||
- script: make -j$(sysctl -n hw.ncpu) -C $(BuildType)
|
||||
displayName: Make
|
||||
- script: ctest --verbose --timeout 180
|
||||
- script: ctest --verbose --timeout 240
|
||||
workingDirectory: $(BuildType)
|
||||
displayName: CTest
|
||||
|
||||
|
|
Binary file not shown.
BIN
bin/minject.exe
BIN
bin/minject.exe
Binary file not shown.
Binary file not shown.
|
@ -484,18 +484,27 @@ typedef struct mi_stats_s {
|
|||
} mi_stats_t;
|
||||
|
||||
|
||||
// add to stat keeping track of the peak
|
||||
void _mi_stat_increase(mi_stat_count_t* stat, size_t amount);
|
||||
void _mi_stat_decrease(mi_stat_count_t* stat, size_t amount);
|
||||
// adjust stat in special cases to compensate for double counting
|
||||
void _mi_stat_adjust_increase(mi_stat_count_t* stat, size_t amount);
|
||||
void _mi_stat_adjust_decrease(mi_stat_count_t* stat, size_t amount);
|
||||
// counters can just be increased
|
||||
void _mi_stat_counter_increase(mi_stat_counter_t* stat, size_t amount);
|
||||
|
||||
#if (MI_STAT)
|
||||
#define mi_stat_increase(stat,amount) _mi_stat_increase( &(stat), amount)
|
||||
#define mi_stat_decrease(stat,amount) _mi_stat_decrease( &(stat), amount)
|
||||
#define mi_stat_counter_increase(stat,amount) _mi_stat_counter_increase( &(stat), amount)
|
||||
#define mi_stat_adjust_increase(stat,amount) _mi_stat_adjust_increase( &(stat), amount)
|
||||
#define mi_stat_adjust_decrease(stat,amount) _mi_stat_adjust_decrease( &(stat), amount)
|
||||
#else
|
||||
#define mi_stat_increase(stat,amount) (void)0
|
||||
#define mi_stat_decrease(stat,amount) (void)0
|
||||
#define mi_stat_counter_increase(stat,amount) (void)0
|
||||
#define mi_stat_increase(stat,amount) ((void)0)
|
||||
#define mi_stat_decrease(stat,amount) ((void)0)
|
||||
#define mi_stat_counter_increase(stat,amount) ((void)0)
|
||||
#define mi_stat_adjuct_increase(stat,amount) ((void)0)
|
||||
#define mi_stat_adjust_decrease(stat,amount) ((void)0)
|
||||
#endif
|
||||
|
||||
#define mi_heap_stat_counter_increase(heap,stat,amount) mi_stat_counter_increase( (heap)->tld->stats.stat, amount)
|
||||
|
|
31
src/stats.c
31
src/stats.c
|
@ -26,7 +26,7 @@ static bool mi_is_in_main(void* stat) {
|
|||
|
||||
static void mi_stat_update(mi_stat_count_t* stat, int64_t amount) {
|
||||
if (amount == 0) return;
|
||||
if (mi_is_in_main(stat))
|
||||
if mi_unlikely(mi_is_in_main(stat))
|
||||
{
|
||||
// add atomically (for abandoned pages)
|
||||
int64_t current = mi_atomic_addi64_relaxed(&stat->current, amount);
|
||||
|
@ -51,6 +51,27 @@ static void mi_stat_update(mi_stat_count_t* stat, int64_t amount) {
|
|||
}
|
||||
}
|
||||
|
||||
// Adjust stats to compensate; for example before committing a range,
|
||||
// first adjust downwards with parts that were already committed so
|
||||
// we avoid double counting.
|
||||
static void mi_stat_adjust(mi_stat_count_t* stat, int64_t amount) {
|
||||
if (amount == 0) return;
|
||||
if mi_unlikely(mi_is_in_main(stat))
|
||||
{
|
||||
// adjust atomically
|
||||
mi_atomic_addi64_relaxed(&stat->current, amount);
|
||||
mi_atomic_addi64_relaxed(&stat->allocated, amount);
|
||||
mi_atomic_addi64_relaxed(&stat->freed, amount);
|
||||
}
|
||||
else {
|
||||
// don't affect the peak
|
||||
stat->current += amount;
|
||||
// add to both
|
||||
stat->allocated += amount;
|
||||
stat->freed += amount;
|
||||
}
|
||||
}
|
||||
|
||||
void _mi_stat_counter_increase(mi_stat_counter_t* stat, size_t amount) {
|
||||
if (mi_is_in_main(stat)) {
|
||||
mi_atomic_addi64_relaxed( &stat->count, 1 );
|
||||
|
@ -70,6 +91,14 @@ void _mi_stat_decrease(mi_stat_count_t* stat, size_t amount) {
|
|||
mi_stat_update(stat, -((int64_t)amount));
|
||||
}
|
||||
|
||||
void _mi_stat_adjust_increase(mi_stat_count_t* stat, size_t amount) {
|
||||
mi_stat_adjust(stat, (int64_t)amount);
|
||||
}
|
||||
|
||||
void _mi_stat_adjust_decrease(mi_stat_count_t* stat, size_t amount) {
|
||||
mi_stat_adjust(stat, -((int64_t)amount));
|
||||
}
|
||||
|
||||
// must be thread safe as it is called from stats_merge
|
||||
static void mi_stat_add(mi_stat_count_t* stat, const mi_stat_count_t* src, int64_t unit) {
|
||||
if (stat==src) return;
|
||||
|
|
Loading…
Add table
Reference in a new issue