@@ -24,6 +24,7 @@ terms of the MIT license. A copy of the license can be found in the file
2424#include <stddef.h> // ptrdiff_t
2525#include <stdint.h> // uintptr_t, uint16_t, etc
2626#include "atomic.h" // _Atomic
27+ #include "stats.h"
2728
2829#ifdef _MSC_VER
2930#pragma warning(disable:4214) // bitfield is not int
@@ -200,9 +201,6 @@ typedef int32_t mi_ssize_t;
200201#define MI_LARGE_OBJ_SIZE_MAX (MI_LARGE_PAGE_SIZE/4) // 1 MiB
201202#define MI_LARGE_OBJ_WSIZE_MAX (MI_LARGE_OBJ_SIZE_MAX/MI_INTPTR_SIZE)
202203
203- // Maximum number of size classes. (spaced exponentially in 12.5% increments)
204- #define MI_BIN_HUGE (73U)
205-
206204#if (MI_LARGE_OBJ_WSIZE_MAX >= 655360 )
207205#error "mimalloc internal: define more bins"
208206#endif
@@ -552,63 +550,9 @@ void _mi_assert_fail(const char* assertion, const char* fname, unsigned int line
552550
553551// ------------------------------------------------------
554552// Statistics
553+ // declare statistics functions here (not stats.h) to avoid exposing these to library consumers
555554// ------------------------------------------------------
556555
557- #ifndef MI_STAT
558- #if (MI_DEBUG > 0 )
559- #define MI_STAT 2
560- #else
561- #define MI_STAT 0
562- #endif
563- #endif
564-
565- typedef struct mi_stat_count_s {
566- int64_t allocated ;
567- int64_t freed ;
568- int64_t peak ;
569- int64_t current ;
570- } mi_stat_count_t ;
571-
572- typedef struct mi_stat_counter_s {
573- int64_t total ;
574- int64_t count ;
575- } mi_stat_counter_t ;
576-
577- typedef struct mi_stats_s {
578- mi_stat_count_t segments ;
579- mi_stat_count_t pages ;
580- mi_stat_count_t reserved ;
581- mi_stat_count_t committed ;
582- mi_stat_count_t reset ;
583- mi_stat_count_t purged ;
584- mi_stat_count_t page_committed ;
585- mi_stat_count_t segments_abandoned ;
586- mi_stat_count_t pages_abandoned ;
587- mi_stat_count_t threads ;
588- mi_stat_count_t normal ;
589- mi_stat_count_t huge ;
590- mi_stat_count_t giant ;
591- mi_stat_count_t malloc ;
592- mi_stat_count_t segments_cache ;
593- mi_stat_counter_t pages_extended ;
594- mi_stat_counter_t mmap_calls ;
595- mi_stat_counter_t commit_calls ;
596- mi_stat_counter_t reset_calls ;
597- mi_stat_counter_t purge_calls ;
598- mi_stat_counter_t page_no_retire ;
599- mi_stat_counter_t searches ;
600- mi_stat_counter_t normal_count ;
601- mi_stat_counter_t huge_count ;
602- mi_stat_counter_t arena_count ;
603- mi_stat_counter_t arena_crossover_count ;
604- mi_stat_counter_t arena_rollback_count ;
605- mi_stat_counter_t guarded_alloc_count ;
606- #if MI_STAT > 1
607- mi_stat_count_t normal_bins [MI_BIN_HUGE + 1 ];
608- #endif
609- } mi_stats_t ;
610-
611-
612556// add to stat keeping track of the peak
613557void _mi_stat_increase (mi_stat_count_t * stat , size_t amount );
614558void _mi_stat_decrease (mi_stat_count_t * stat , size_t amount );
@@ -636,7 +580,6 @@ void _mi_stat_counter_increase(mi_stat_counter_t* stat, size_t amount);
636580#define mi_heap_stat_increase (heap ,stat ,amount ) mi_stat_increase( (heap)->tld->stats.stat, amount)
637581#define mi_heap_stat_decrease (heap ,stat ,amount ) mi_stat_decrease( (heap)->tld->stats.stat, amount)
638582
639-
640583// ------------------------------------------------------
641584// Sub processes do not reclaim or visit segments
642585// from other sub processes
0 commit comments