TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
stats.h
Go to the documentation of this file.
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
3 
4 typedef struct tcache_bin_stats_s tcache_bin_stats_t;
5 typedef struct malloc_bin_stats_s malloc_bin_stats_t;
6 typedef struct malloc_large_stats_s malloc_large_stats_t;
7 typedef struct arena_stats_s arena_stats_t;
8 typedef struct chunk_stats_s chunk_stats_t;
9 
10 #endif /* JEMALLOC_H_TYPES */
11 /******************************************************************************/
12 #ifdef JEMALLOC_H_STRUCTS
13 
14 struct tcache_bin_stats_s {
15  /*
16  * Number of allocation requests that corresponded to the size of this
17  * bin.
18  */
19  uint64_t nrequests;
20 };
21 
22 struct malloc_bin_stats_s {
23  /*
24  * Current number of bytes allocated, including objects currently
25  * cached by tcache.
26  */
27  size_t allocated;
28 
29  /*
30  * Total number of allocation/deallocation requests served directly by
31  * the bin. Note that tcache may allocate an object, then recycle it
32  * many times, resulting many increments to nrequests, but only one
33  * each to nmalloc and ndalloc.
34  */
35  uint64_t nmalloc;
36  uint64_t ndalloc;
37 
38  /*
39  * Number of allocation requests that correspond to the size of this
40  * bin. This includes requests served by tcache, though tcache only
41  * periodically merges into this counter.
42  */
43  uint64_t nrequests;
44 
45  /* Number of tcache fills from this bin. */
46  uint64_t nfills;
47 
48  /* Number of tcache flushes to this bin. */
49  uint64_t nflushes;
50 
51  /* Total number of runs created for this bin's size class. */
52  uint64_t nruns;
53 
54  /*
55  * Total number of runs reused by extracting them from the runs tree for
56  * this bin's size class.
57  */
58  uint64_t reruns;
59 
60  /* Current number of runs in this bin. */
61  size_t curruns;
62 };
63 
64 struct malloc_large_stats_s {
65  /*
66  * Total number of allocation/deallocation requests served directly by
67  * the arena. Note that tcache may allocate an object, then recycle it
68  * many times, resulting many increments to nrequests, but only one
69  * each to nmalloc and ndalloc.
70  */
71  uint64_t nmalloc;
72  uint64_t ndalloc;
73 
74  /*
75  * Number of allocation requests that correspond to this size class.
76  * This includes requests served by tcache, though tcache only
77  * periodically merges into this counter.
78  */
79  uint64_t nrequests;
80 
81  /* Current number of runs of this size class. */
82  size_t curruns;
83 };
84 
85 struct arena_stats_s {
86  /* Number of bytes currently mapped. */
87  size_t mapped;
88 
89  /*
90  * Total number of purge sweeps, total number of madvise calls made,
91  * and total pages purged in order to keep dirty unused memory under
92  * control.
93  */
94  uint64_t npurge;
95  uint64_t nmadvise;
96  uint64_t purged;
97 
98  /* Per-size-category statistics. */
99  size_t allocated_large;
100  uint64_t nmalloc_large;
101  uint64_t ndalloc_large;
102  uint64_t nrequests_large;
103 
104  /*
105  * One element for each possible size class, including sizes that
106  * overlap with bin size classes. This is necessary because ipalloc()
107  * sometimes has to use such large objects in order to assure proper
108  * alignment.
109  */
110  malloc_large_stats_t *lstats;
111 };
112 
113 struct chunk_stats_s {
114  /* Number of chunks that were allocated. */
115  uint64_t nchunks;
116 
117  /* High-water mark for number of chunks allocated. */
118  size_t highchunks;
119 
120  /*
121  * Current number of chunks allocated. This value isn't maintained for
122  * any other purpose, so keep track of it in order to be able to set
123  * highchunks.
124  */
125  size_t curchunks;
126 };
127 
128 #endif /* JEMALLOC_H_STRUCTS */
129 /******************************************************************************/
130 #ifdef JEMALLOC_H_EXTERNS
131 
132 extern bool opt_stats_print;
133 
134 extern size_t stats_cactive;
135 
136 void stats_print(void (*write)(void *, const char *), void *cbopaque,
137  const char *opts);
138 
139 #endif /* JEMALLOC_H_EXTERNS */
140 /******************************************************************************/
141 #ifdef JEMALLOC_H_INLINES
142 
143 #ifndef JEMALLOC_ENABLE_INLINE
144 size_t stats_cactive_get(void);
145 void stats_cactive_add(size_t size);
146 void stats_cactive_sub(size_t size);
147 #endif
148 
149 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_STATS_C_))
150 JEMALLOC_INLINE size_t
151 stats_cactive_get(void)
152 {
153 
154  return (atomic_read_z(&stats_cactive));
155 }
156 
157 JEMALLOC_INLINE void
158 stats_cactive_add(size_t size)
159 {
160 
161  atomic_add_z(&stats_cactive, size);
162 }
163 
164 JEMALLOC_INLINE void
165 stats_cactive_sub(size_t size)
166 {
167 
168  atomic_sub_z(&stats_cactive, size);
169 }
170 #endif
171 
172 #endif /* JEMALLOC_H_INLINES */
173 /******************************************************************************/
#define JEMALLOC_INLINE
Definition: jemalloc_internal.h:259
#define stats_cactive
Definition: private_namespace.h:350
#define stats_cactive_get
Definition: private_namespace.h:352
#define opt_stats_print
Definition: private_namespace.h:279
#define stats_print
Definition: private_namespace.h:355
#define atomic_add_z
Definition: private_namespace.h:80
unsigned __int64 uint64_t
Definition: stdint.h:90
#define stats_cactive_sub
Definition: private_namespace.h:353
#define stats_cactive_add
Definition: private_namespace.h:351
#define atomic_sub_z
Definition: private_namespace.h:84