1 #ifndef JEMALLOC_INTERNAL_STATS_H 2 #define JEMALLOC_INTERNAL_STATS_H 3 4 /* OPTION(opt, var_name, default, set_value_to) */ 5 #define STATS_PRINT_OPTIONS \ 6 OPTION('J', json, false, true) \ 7 OPTION('g', general, true, false) \ 8 OPTION('m', merged, config_stats, false) \ 9 OPTION('d', destroyed, config_stats, false) \ 10 OPTION('a', unmerged, config_stats, false) \ 11 OPTION('b', bins, true, false) \ 12 OPTION('l', large, true, false) \ 13 OPTION('x', mutex, true, false) \ 14 OPTION('e', extents, true, false) \ 15 OPTION('h', hpa, config_stats, false) 16 17 enum { 18 #define OPTION(o, v, d, s) stats_print_option_num_##v, 19 STATS_PRINT_OPTIONS 20 #undef OPTION 21 stats_print_tot_num_options 22 }; 23 24 /* Options for stats_print. */ 25 extern bool opt_stats_print; 26 extern char opt_stats_print_opts[stats_print_tot_num_options+1]; 27 28 /* Utilities for stats_interval. */ 29 extern int64_t opt_stats_interval; 30 extern char opt_stats_interval_opts[stats_print_tot_num_options+1]; 31 32 #define STATS_INTERVAL_DEFAULT -1 33 /* 34 * Batch-increment the counter to reduce synchronization overhead. Each thread 35 * merges after (interval >> LG_BATCH_SIZE) bytes of allocations; also limit the 36 * BATCH_MAX for accuracy when the interval is huge (which is expected). 37 */ 38 #define STATS_INTERVAL_ACCUM_LG_BATCH_SIZE 6 39 #define STATS_INTERVAL_ACCUM_BATCH_MAX (4 << 20) 40 41 /* Only accessed by thread event. */ 42 uint64_t stats_interval_new_event_wait(tsd_t *tsd); 43 uint64_t stats_interval_postponed_event_wait(tsd_t *tsd); 44 void stats_interval_event_handler(tsd_t *tsd, uint64_t elapsed); 45 46 /* Implements je_malloc_stats_print. */ 47 void stats_print(write_cb_t *write_cb, void *cbopaque, const char *opts); 48 49 bool stats_boot(void); 50 void stats_prefork(tsdn_t *tsdn); 51 void stats_postfork_parent(tsdn_t *tsdn); 52 void stats_postfork_child(tsdn_t *tsdn); 53 54 #endif /* JEMALLOC_INTERNAL_STATS_H */ 55