1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
3 #ident "$Id$"
4 /*======
5 This file is part of PerconaFT.
6 
7 
8 Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
9 
10     PerconaFT is free software: you can redistribute it and/or modify
11     it under the terms of the GNU General Public License, version 2,
12     as published by the Free Software Foundation.
13 
14     PerconaFT is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18 
19     You should have received a copy of the GNU General Public License
20     along with PerconaFT.  If not, see <http://www.gnu.org/licenses/>.
21 
22 ----------------------------------------
23 
24     PerconaFT is free software: you can redistribute it and/or modify
25     it under the terms of the GNU Affero General Public License, version 3,
26     as published by the Free Software Foundation.
27 
28     PerconaFT is distributed in the hope that it will be useful,
29     but WITHOUT ANY WARRANTY; without even the implied warranty of
30     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31     GNU Affero General Public License for more details.
32 
33     You should have received a copy of the GNU Affero General Public License
34     along with PerconaFT.  If not, see <http://www.gnu.org/licenses/>.
35 
36 ----------------------------------------
37 
38    Licensed under the Apache License, Version 2.0 (the "License");
39    you may not use this file except in compliance with the License.
40    You may obtain a copy of the License at
41 
42        http://www.apache.org/licenses/LICENSE-2.0
43 
44    Unless required by applicable law or agreed to in writing, software
45    distributed under the License is distributed on an "AS IS" BASIS,
46    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47    See the License for the specific language governing permissions and
48    limitations under the License.
49 ======= */
50 
51 #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
52 
53 #include <my_global.h>
54 #include "ft/ft.h"
55 #include "ft/ft-status.h"
56 
57 #include <toku_race_tools.h>
58 
59 LE_STATUS_S le_status;
init()60 void LE_STATUS_S::init() {
61     if (m_initialized) return;
62 #define LE_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "le: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
63     LE_STATUS_INIT(LE_MAX_COMMITTED_XR,     LEAF_ENTRY_MAX_COMMITTED_XR,    UINT64,     "max committed xr");
64     LE_STATUS_INIT(LE_MAX_PROVISIONAL_XR,   LEAF_ENTRY_MAX_PROVISIONAL_XR,  UINT64,     "max provisional xr");
65     LE_STATUS_INIT(LE_EXPANDED,             LEAF_ENTRY_EXPANDED,            UINT64,     "expanded");
66     LE_STATUS_INIT(LE_MAX_MEMSIZE,          LEAF_ENTRY_MAX_MEMSIZE,         UINT64,     "max memsize");
67     LE_STATUS_INIT(LE_APPLY_GC_BYTES_IN,    LEAF_ENTRY_APPLY_GC_BYTES_IN,   PARCOUNT,   "size of leafentries before garbage collection (during message application)");
68     LE_STATUS_INIT(LE_APPLY_GC_BYTES_OUT,   LEAF_ENTRY_APPLY_GC_BYTES_OUT,  PARCOUNT,   "size of leafentries after garbage collection (during message application)");
69     LE_STATUS_INIT(LE_NORMAL_GC_BYTES_IN,   LEAF_ENTRY_NORMAL_GC_BYTES_IN,  PARCOUNT,   "size of leafentries before garbage collection (outside message application)");
70     LE_STATUS_INIT(LE_NORMAL_GC_BYTES_OUT,  LEAF_ENTRY_NORMAL_GC_BYTES_OUT, PARCOUNT,   "size of leafentries after garbage collection (outside message application)");
71     m_initialized = true;
72 #undef LE_STATUS_INIT
73 }
destroy()74 void LE_STATUS_S::destroy() {
75     if (!m_initialized) return;
76     for (int i = 0; i < LE_STATUS_NUM_ROWS; ++i) {
77         if (status[i].type == PARCOUNT) {
78             destroy_partitioned_counter(status[i].value.parcount);
79         }
80     }
81 }
82 
83 
84 
85 CHECKPOINT_STATUS_S cp_status;
init(void)86 void CHECKPOINT_STATUS_S::init(void) {
87     if (m_initialized) return;
88 #define CP_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "checkpoint: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
89     CP_STATUS_INIT(CP_PERIOD,                               CHECKPOINT_PERIOD,              UINT64,     "period");
90     CP_STATUS_INIT(CP_FOOTPRINT,                            CHECKPOINT_FOOTPRINT,           UINT64,     "footprint");
91     CP_STATUS_INIT(CP_TIME_LAST_CHECKPOINT_BEGIN,           CHECKPOINT_LAST_BEGAN,          UNIXTIME,   "last checkpoint began");
92     CP_STATUS_INIT(CP_TIME_LAST_CHECKPOINT_BEGIN_COMPLETE,  CHECKPOINT_LAST_COMPLETE_BEGAN, UNIXTIME,   "last complete checkpoint began");
93     CP_STATUS_INIT(CP_TIME_LAST_CHECKPOINT_END,             CHECKPOINT_LAST_COMPLETE_ENDED, UNIXTIME,   "last complete checkpoint ended");
94     CP_STATUS_INIT(CP_TIME_CHECKPOINT_DURATION,             CHECKPOINT_DURATION,            UINT64,     "time spent during checkpoint (begin and end phases)");
95     CP_STATUS_INIT(CP_TIME_CHECKPOINT_DURATION_LAST,        CHECKPOINT_DURATION_LAST,       UINT64,     "time spent during last checkpoint (begin and end phases)");
96     CP_STATUS_INIT(CP_LAST_LSN,                             CHECKPOINT_LAST_LSN,            UINT64,     "last complete checkpoint LSN");
97     CP_STATUS_INIT(CP_CHECKPOINT_COUNT,                     CHECKPOINT_TAKEN,               UINT64,     "checkpoints taken ");
98     CP_STATUS_INIT(CP_CHECKPOINT_COUNT_FAIL,                CHECKPOINT_FAILED,              UINT64,     "checkpoints failed");
99     CP_STATUS_INIT(CP_WAITERS_NOW,                          CHECKPOINT_WAITERS_NOW,         UINT64,     "waiters now");
100     CP_STATUS_INIT(CP_WAITERS_MAX,                          CHECKPOINT_WAITERS_MAX,         UINT64,     "waiters max");
101     CP_STATUS_INIT(CP_CLIENT_WAIT_ON_MO,                    CHECKPOINT_CLIENT_WAIT_ON_MO,   UINT64,     "non-checkpoint client wait on mo lock");
102     CP_STATUS_INIT(CP_CLIENT_WAIT_ON_CS,                    CHECKPOINT_CLIENT_WAIT_ON_CS,   UINT64,     "non-checkpoint client wait on cs lock");
103     CP_STATUS_INIT(CP_BEGIN_TIME,                           CHECKPOINT_BEGIN_TIME,          UINT64,     "checkpoint begin time");
104     CP_STATUS_INIT(CP_LONG_BEGIN_COUNT,                     CHECKPOINT_LONG_BEGIN_COUNT,    UINT64,     "long checkpoint begin count");
105     CP_STATUS_INIT(CP_LONG_BEGIN_TIME,                      CHECKPOINT_LONG_BEGIN_TIME,     UINT64,     "long checkpoint begin time");
106     CP_STATUS_INIT(CP_END_TIME,                             CHECKPOINT_END_TIME,            UINT64,     "checkpoint end time");
107     CP_STATUS_INIT(CP_LONG_END_COUNT,                       CHECKPOINT_LONG_END_COUNT,      UINT64,     "long checkpoint end count");
108     CP_STATUS_INIT(CP_LONG_END_TIME,                        CHECKPOINT_LONG_END_TIME,       UINT64,     "long checkpoint end time");
109 
110     m_initialized = true;
111 #undef CP_STATUS_INIT
112 }
destroy()113 void CHECKPOINT_STATUS_S::destroy() {
114     if (!m_initialized) return;
115     for (int i = 0; i < CP_STATUS_NUM_ROWS; ++i) {
116         if (status[i].type == PARCOUNT) {
117             destroy_partitioned_counter(status[i].value.parcount);
118         }
119     }
120 }
121 
122 CACHETABLE_STATUS_S ct_status;
init()123 void CACHETABLE_STATUS_S::init() {
124     if (m_initialized) return;
125 #define CT_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "cachetable: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
126     CT_STATUS_INIT(CT_MISS,                     CACHETABLE_MISS,                        UINT64, "miss");
127     CT_STATUS_INIT(CT_MISSTIME,                 CACHETABLE_MISS_TIME,                   UINT64, "miss time");
128     CT_STATUS_INIT(CT_PREFETCHES,               CACHETABLE_PREFETCHES,                  UINT64, "prefetches");
129     CT_STATUS_INIT(CT_SIZE_CURRENT,             CACHETABLE_SIZE_CURRENT,                UINT64, "size current");
130     CT_STATUS_INIT(CT_SIZE_LIMIT,               CACHETABLE_SIZE_LIMIT,                  UINT64, "size limit");
131     CT_STATUS_INIT(CT_SIZE_WRITING,             CACHETABLE_SIZE_WRITING,                UINT64, "size writing");
132     CT_STATUS_INIT(CT_SIZE_NONLEAF,             CACHETABLE_SIZE_NONLEAF,                UINT64, "size nonleaf");
133     CT_STATUS_INIT(CT_SIZE_LEAF,                CACHETABLE_SIZE_LEAF,                   UINT64, "size leaf");
134     CT_STATUS_INIT(CT_SIZE_ROLLBACK,            CACHETABLE_SIZE_ROLLBACK,               UINT64, "size rollback");
135     CT_STATUS_INIT(CT_SIZE_CACHEPRESSURE,       CACHETABLE_SIZE_CACHEPRESSURE,          UINT64, "size cachepressure");
136     CT_STATUS_INIT(CT_SIZE_CLONED,              CACHETABLE_SIZE_CLONED,                 UINT64, "size currently cloned data for checkpoint");
137     CT_STATUS_INIT(CT_EVICTIONS,                CACHETABLE_EVICTIONS,                   UINT64, "evictions");
138     CT_STATUS_INIT(CT_CLEANER_EXECUTIONS,       CACHETABLE_CLEANER_EXECUTIONS,          UINT64, "cleaner executions");
139     CT_STATUS_INIT(CT_CLEANER_PERIOD,           CACHETABLE_CLEANER_PERIOD,              UINT64, "cleaner period");
140     CT_STATUS_INIT(CT_CLEANER_ITERATIONS,       CACHETABLE_CLEANER_ITERATIONS,          UINT64, "cleaner iterations");
141     CT_STATUS_INIT(CT_WAIT_PRESSURE_COUNT,      CACHETABLE_WAIT_PRESSURE_COUNT,         UINT64, "number of waits on cache pressure");
142     CT_STATUS_INIT(CT_WAIT_PRESSURE_TIME,       CACHETABLE_WAIT_PRESSURE_TIME,          UINT64, "time waiting on cache pressure");
143     CT_STATUS_INIT(CT_LONG_WAIT_PRESSURE_COUNT, CACHETABLE_LONG_WAIT_PRESSURE_COUNT,    UINT64, "number of long waits on cache pressure");
144     CT_STATUS_INIT(CT_LONG_WAIT_PRESSURE_TIME,  CACHETABLE_LONG_WAIT_PRESSURE_TIME,     UINT64, "long time waiting on cache pressure");
145 
146     CT_STATUS_INIT(CT_POOL_CLIENT_NUM_THREADS,                  CACHETABLE_POOL_CLIENT_NUM_THREADS,                 UINT64, "client pool: number of threads in pool");
147     CT_STATUS_INIT(CT_POOL_CLIENT_NUM_THREADS_ACTIVE,           CACHETABLE_POOL_CLIENT_NUM_THREADS_ACTIVE,          UINT64, "client pool: number of currently active threads in pool");
148     CT_STATUS_INIT(CT_POOL_CLIENT_QUEUE_SIZE,                   CACHETABLE_POOL_CLIENT_QUEUE_SIZE,                  UINT64, "client pool: number of currently queued work items");
149     CT_STATUS_INIT(CT_POOL_CLIENT_MAX_QUEUE_SIZE,               CACHETABLE_POOL_CLIENT_MAX_QUEUE_SIZE,              UINT64, "client pool: largest number of queued work items");
150     CT_STATUS_INIT(CT_POOL_CLIENT_TOTAL_ITEMS_PROCESSED,        CACHETABLE_POOL_CLIENT_TOTAL_ITEMS_PROCESSED,       UINT64, "client pool: total number of work items processed");
151     CT_STATUS_INIT(CT_POOL_CLIENT_TOTAL_EXECUTION_TIME,         CACHETABLE_POOL_CLIENT_TOTAL_EXECUTION_TIME,        UINT64, "client pool: total execution time of processing work items");
152     CT_STATUS_INIT(CT_POOL_CACHETABLE_NUM_THREADS,              CACHETABLE_POOL_CACHETABLE_NUM_THREADS,             UINT64, "cachetable pool: number of threads in pool");
153     CT_STATUS_INIT(CT_POOL_CACHETABLE_NUM_THREADS_ACTIVE,       CACHETABLE_POOL_CACHETABLE_NUM_THREADS_ACTIVE,      UINT64, "cachetable pool: number of currently active threads in pool");
154     CT_STATUS_INIT(CT_POOL_CACHETABLE_QUEUE_SIZE,               CACHETABLE_POOL_CACHETABLE_QUEUE_SIZE,              UINT64, "cachetable pool: number of currently queued work items");
155     CT_STATUS_INIT(CT_POOL_CACHETABLE_MAX_QUEUE_SIZE,           CACHETABLE_POOL_CACHETABLE_MAX_QUEUE_SIZE,          UINT64, "cachetable pool: largest number of queued work items");
156     CT_STATUS_INIT(CT_POOL_CACHETABLE_TOTAL_ITEMS_PROCESSED,    CACHETABLE_POOL_CACHETABLE_TOTAL_ITEMS_PROCESSED,   UINT64, "cachetable pool: total number of work items processed");
157     CT_STATUS_INIT(CT_POOL_CACHETABLE_TOTAL_EXECUTION_TIME,     CACHETABLE_POOL_CACHETABLE_TOTAL_EXECUTION_TIME,    UINT64, "cachetable pool: total execution time of processing work items");
158     CT_STATUS_INIT(CT_POOL_CHECKPOINT_NUM_THREADS,              CACHETABLE_POOL_CHECKPOINT_NUM_THREADS,             UINT64, "checkpoint pool: number of threads in pool");
159     CT_STATUS_INIT(CT_POOL_CHECKPOINT_NUM_THREADS_ACTIVE,       CACHETABLE_POOL_CHECKPOINT_NUM_THREADS_ACTIVE,      UINT64, "checkpoint pool: number of currently active threads in pool");
160     CT_STATUS_INIT(CT_POOL_CHECKPOINT_QUEUE_SIZE,               CACHETABLE_POOL_CHECKPOINT_QUEUE_SIZE,              UINT64, "checkpoint pool: number of currently queued work items");
161     CT_STATUS_INIT(CT_POOL_CHECKPOINT_MAX_QUEUE_SIZE,           CACHETABLE_POOL_CHECKPOINT_MAX_QUEUE_SIZE,          UINT64, "checkpoint pool: largest number of queued work items");
162     CT_STATUS_INIT(CT_POOL_CHECKPOINT_TOTAL_ITEMS_PROCESSED,    CACHETABLE_POOL_CHECKPOINT_TOTAL_ITEMS_PROCESSED,   UINT64, "checkpoint pool: total number of work items processed");
163     CT_STATUS_INIT(CT_POOL_CHECKPOINT_TOTAL_EXECUTION_TIME,     CACHETABLE_POOL_CHECKPOINT_TOTAL_EXECUTION_TIME,    UINT64, "checkpoint pool: total execution time of processing work items");
164 
165     m_initialized = true;
166 #undef CT_STATUS_INIT
167 }
destroy()168 void CACHETABLE_STATUS_S::destroy() {
169     if (!m_initialized) return;
170     for (int i = 0; i < CT_STATUS_NUM_ROWS; ++i) {
171         if (status[i].type == PARCOUNT) {
172             destroy_partitioned_counter(status[i].value.parcount);
173         }
174     }
175 }
176 
177 
178 
179 LTM_STATUS_S ltm_status;
init()180 void LTM_STATUS_S::init() {
181     if (m_initialized) return;
182 #define LTM_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "locktree: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
183     LTM_STATUS_INIT(LTM_SIZE_CURRENT,               LOCKTREE_MEMORY_SIZE,                   UINT64, "memory size");
184     LTM_STATUS_INIT(LTM_SIZE_LIMIT,                 LOCKTREE_MEMORY_SIZE_LIMIT,             UINT64, "memory size limit");
185     LTM_STATUS_INIT(LTM_ESCALATION_COUNT,           LOCKTREE_ESCALATION_NUM,                UINT64, "number of times lock escalation ran");
186     LTM_STATUS_INIT(LTM_ESCALATION_TIME,            LOCKTREE_ESCALATION_SECONDS,            TOKUTIME, "time spent running escalation (seconds)");
187     LTM_STATUS_INIT(LTM_ESCALATION_LATEST_RESULT,   LOCKTREE_LATEST_POST_ESCALATION_MEMORY_SIZE, UINT64, "latest post-escalation memory size");
188     LTM_STATUS_INIT(LTM_NUM_LOCKTREES,              LOCKTREE_OPEN_CURRENT,                  UINT64, "number of locktrees open now");
189     LTM_STATUS_INIT(LTM_LOCK_REQUESTS_PENDING,      LOCKTREE_PENDING_LOCK_REQUESTS,         UINT64, "number of pending lock requests");
190     LTM_STATUS_INIT(LTM_STO_NUM_ELIGIBLE,           LOCKTREE_STO_ELIGIBLE_NUM,              UINT64, "number of locktrees eligible for the STO");
191     LTM_STATUS_INIT(LTM_STO_END_EARLY_COUNT,        LOCKTREE_STO_ENDED_NUM,                 UINT64, "number of times a locktree ended the STO early");
192     LTM_STATUS_INIT(LTM_STO_END_EARLY_TIME,         LOCKTREE_STO_ENDED_SECONDS,             TOKUTIME, "time spent ending the STO early (seconds)");
193     LTM_STATUS_INIT(LTM_WAIT_COUNT,                 LOCKTREE_WAIT_COUNT,                    UINT64, "number of wait locks");
194     LTM_STATUS_INIT(LTM_WAIT_TIME,                  LOCKTREE_WAIT_TIME,                     UINT64, "time waiting for locks");
195     LTM_STATUS_INIT(LTM_LONG_WAIT_COUNT,            LOCKTREE_LONG_WAIT_COUNT,               UINT64, "number of long wait locks");
196     LTM_STATUS_INIT(LTM_LONG_WAIT_TIME,             LOCKTREE_LONG_WAIT_TIME,                UINT64, "long time waiting for locks");
197     LTM_STATUS_INIT(LTM_TIMEOUT_COUNT,              LOCKTREE_TIMEOUT_COUNT,                 UINT64, "number of lock timeouts");
198     LTM_STATUS_INIT(LTM_WAIT_ESCALATION_COUNT,      LOCKTREE_WAIT_ESCALATION_COUNT,         UINT64, "number of waits on lock escalation");
199     LTM_STATUS_INIT(LTM_WAIT_ESCALATION_TIME,       LOCKTREE_WAIT_ESCALATION_TIME,          UINT64, "time waiting on lock escalation");
200     LTM_STATUS_INIT(LTM_LONG_WAIT_ESCALATION_COUNT, LOCKTREE_LONG_WAIT_ESCALATION_COUNT,    UINT64, "number of long waits on lock escalation");
201     LTM_STATUS_INIT(LTM_LONG_WAIT_ESCALATION_TIME,  LOCKTREE_LONG_WAIT_ESCALATION_TIME,     UINT64, "long time waiting on lock escalation");
202 
203     m_initialized = true;
204 #undef LTM_STATUS_INIT
205 }
destroy()206 void LTM_STATUS_S::destroy() {
207     if (!m_initialized) return;
208     for (int i = 0; i < LTM_STATUS_NUM_ROWS; ++i) {
209         if (status[i].type == PARCOUNT) {
210             destroy_partitioned_counter(status[i].value.parcount);
211         }
212     }
213 }
214 
215 
216 
217 FT_STATUS_S ft_status;
init()218 void FT_STATUS_S::init() {
219     if (m_initialized) return;
220 #define FT_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "ft: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
221     FT_STATUS_INIT(FT_UPDATES,                                DICTIONARY_UPDATES,                   PARCOUNT, "dictionary updates");
222     FT_STATUS_INIT(FT_UPDATES_BROADCAST,                      DICTIONARY_BROADCAST_UPDATES,         PARCOUNT, "dictionary broadcast updates");
223     FT_STATUS_INIT(FT_DESCRIPTOR_SET,                         DESCRIPTOR_SET,                       PARCOUNT, "descriptor set");
224     FT_STATUS_INIT(FT_MSN_DISCARDS,                           MESSAGES_IGNORED_BY_LEAF_DUE_TO_MSN,  PARCOUNT, "messages ignored by leaf due to msn");
225     FT_STATUS_INIT(FT_TOTAL_RETRIES,                          TOTAL_SEARCH_RETRIES,                 PARCOUNT, "total search retries due to TRY_AGAIN");
226     FT_STATUS_INIT(FT_SEARCH_TRIES_GT_HEIGHT,                 SEARCH_TRIES_GT_HEIGHT,               PARCOUNT, "searches requiring more tries than the height of the tree");
227     FT_STATUS_INIT(FT_SEARCH_TRIES_GT_HEIGHTPLUS3,            SEARCH_TRIES_GT_HEIGHTPLUS3,          PARCOUNT, "searches requiring more tries than the height of the tree plus three");
228     FT_STATUS_INIT(FT_CREATE_LEAF,                            LEAF_NODES_CREATED,                   PARCOUNT, "leaf nodes created");
229     FT_STATUS_INIT(FT_CREATE_NONLEAF,                         NONLEAF_NODES_CREATED,                PARCOUNT, "nonleaf nodes created");
230     FT_STATUS_INIT(FT_DESTROY_LEAF,                           LEAF_NODES_DESTROYED,                 PARCOUNT, "leaf nodes destroyed");
231     FT_STATUS_INIT(FT_DESTROY_NONLEAF,                        NONLEAF_NODES_DESTROYED,              PARCOUNT, "nonleaf nodes destroyed");
232     FT_STATUS_INIT(FT_MSG_BYTES_IN,                           MESSAGES_INJECTED_AT_ROOT_BYTES,      PARCOUNT, "bytes of messages injected at root (all trees)");
233     FT_STATUS_INIT(FT_MSG_BYTES_OUT,                          MESSAGES_FLUSHED_FROM_H1_TO_LEAVES_BYTES, PARCOUNT, "bytes of messages flushed from h1 nodes to leaves");
234     FT_STATUS_INIT(FT_MSG_BYTES_CURR,                         MESSAGES_IN_TREES_ESTIMATE_BYTES,     PARCOUNT, "bytes of messages currently in trees (estimate)");
235     FT_STATUS_INIT(FT_MSG_NUM,                                MESSAGES_INJECTED_AT_ROOT,            PARCOUNT, "messages injected at root");
236     FT_STATUS_INIT(FT_MSG_NUM_BROADCAST,                      BROADCASE_MESSAGES_INJECTED_AT_ROOT,  PARCOUNT, "broadcast messages injected at root");
237 
238     FT_STATUS_INIT(FT_NUM_BASEMENTS_DECOMPRESSED_NORMAL,      BASEMENTS_DECOMPRESSED_TARGET_QUERY,  PARCOUNT, "basements decompressed as a target of a query");
239     FT_STATUS_INIT(FT_NUM_BASEMENTS_DECOMPRESSED_AGGRESSIVE,  BASEMENTS_DECOMPRESSED_PRELOCKED_RANGE, PARCOUNT, "basements decompressed for prelocked range");
240     FT_STATUS_INIT(FT_NUM_BASEMENTS_DECOMPRESSED_PREFETCH,    BASEMENTS_DECOMPRESSED_PREFETCH,      PARCOUNT, "basements decompressed for prefetch");
241     FT_STATUS_INIT(FT_NUM_BASEMENTS_DECOMPRESSED_WRITE,       BASEMENTS_DECOMPRESSED_FOR_WRITE,     PARCOUNT, "basements decompressed for write");
242     FT_STATUS_INIT(FT_NUM_MSG_BUFFER_DECOMPRESSED_NORMAL,     BUFFERS_DECOMPRESSED_TARGET_QUERY,    PARCOUNT, "buffers decompressed as a target of a query");
243     FT_STATUS_INIT(FT_NUM_MSG_BUFFER_DECOMPRESSED_AGGRESSIVE, BUFFERS_DECOMPRESSED_PRELOCKED_RANGE, PARCOUNT, "buffers decompressed for prelocked range");
244     FT_STATUS_INIT(FT_NUM_MSG_BUFFER_DECOMPRESSED_PREFETCH,   BUFFERS_DECOMPRESSED_PREFETCH,        PARCOUNT, "buffers decompressed for prefetch");
245     FT_STATUS_INIT(FT_NUM_MSG_BUFFER_DECOMPRESSED_WRITE,      BUFFERS_DECOMPRESSED_FOR_WRITE,       PARCOUNT, "buffers decompressed for write");
246 
247     // Eviction statistics:
248     FT_STATUS_INIT(FT_FULL_EVICTIONS_LEAF,                    LEAF_NODE_FULL_EVICTIONS,             PARCOUNT, "leaf node full evictions");
249     FT_STATUS_INIT(FT_FULL_EVICTIONS_LEAF_BYTES,              LEAF_NODE_FULL_EVICTIONS_BYTES,       PARCOUNT, "leaf node full evictions (bytes)");
250     FT_STATUS_INIT(FT_FULL_EVICTIONS_NONLEAF,                 NONLEAF_NODE_FULL_EVICTIONS,          PARCOUNT, "nonleaf node full evictions");
251     FT_STATUS_INIT(FT_FULL_EVICTIONS_NONLEAF_BYTES,           NONLEAF_NODE_FULL_EVICTIONS_BYTES,    PARCOUNT, "nonleaf node full evictions (bytes)");
252     FT_STATUS_INIT(FT_PARTIAL_EVICTIONS_LEAF,                 LEAF_NODE_PARTIAL_EVICTIONS,          PARCOUNT, "leaf node partial evictions");
253     FT_STATUS_INIT(FT_PARTIAL_EVICTIONS_LEAF_BYTES,           LEAF_NODE_PARTIAL_EVICTIONS_BYTES,    PARCOUNT, "leaf node partial evictions (bytes)");
254     FT_STATUS_INIT(FT_PARTIAL_EVICTIONS_NONLEAF,              NONLEAF_NODE_PARTIAL_EVICTIONS,       PARCOUNT, "nonleaf node partial evictions");
255     FT_STATUS_INIT(FT_PARTIAL_EVICTIONS_NONLEAF_BYTES,        NONLEAF_NODE_PARTIAL_EVICTIONS_BYTES, PARCOUNT, "nonleaf node partial evictions (bytes)");
256 
257     // Disk read statistics:
258     //
259     // Pivots: For queries, prefetching, or writing.
260     FT_STATUS_INIT(FT_NUM_PIVOTS_FETCHED_QUERY,               PIVOTS_FETCHED_FOR_QUERY,             PARCOUNT, "pivots fetched for query");
261     FT_STATUS_INIT(FT_BYTES_PIVOTS_FETCHED_QUERY,             PIVOTS_FETCHED_FOR_QUERY_BYTES,       PARCOUNT, "pivots fetched for query (bytes)");
262     FT_STATUS_INIT(FT_TOKUTIME_PIVOTS_FETCHED_QUERY,          PIVOTS_FETCHED_FOR_QUERY_SECONDS,     TOKUTIME, "pivots fetched for query (seconds)");
263     FT_STATUS_INIT(FT_NUM_PIVOTS_FETCHED_PREFETCH,            PIVOTS_FETCHED_FOR_PREFETCH,          PARCOUNT, "pivots fetched for prefetch");
264     FT_STATUS_INIT(FT_BYTES_PIVOTS_FETCHED_PREFETCH,          PIVOTS_FETCHED_FOR_PREFETCH_BYTES,    PARCOUNT, "pivots fetched for prefetch (bytes)");
265     FT_STATUS_INIT(FT_TOKUTIME_PIVOTS_FETCHED_PREFETCH,       PIVOTS_FETCHED_FOR_PREFETCH_SECONDS,  TOKUTIME, "pivots fetched for prefetch (seconds)");
266     FT_STATUS_INIT(FT_NUM_PIVOTS_FETCHED_WRITE,               PIVOTS_FETCHED_FOR_WRITE,             PARCOUNT, "pivots fetched for write");
267     FT_STATUS_INIT(FT_BYTES_PIVOTS_FETCHED_WRITE,             PIVOTS_FETCHED_FOR_WRITE_BYTES,       PARCOUNT, "pivots fetched for write (bytes)");
268     FT_STATUS_INIT(FT_TOKUTIME_PIVOTS_FETCHED_WRITE,          PIVOTS_FETCHED_FOR_WRITE_SECONDS,     TOKUTIME, "pivots fetched for write (seconds)");
269     // Basements: For queries, aggressive fetching in prelocked range, prefetching, or writing.
270     FT_STATUS_INIT(FT_NUM_BASEMENTS_FETCHED_NORMAL,           BASEMENTS_FETCHED_TARGET_QUERY,       PARCOUNT, "basements fetched as a target of a query");
271     FT_STATUS_INIT(FT_BYTES_BASEMENTS_FETCHED_NORMAL,         BASEMENTS_FETCHED_TARGET_QUERY_BYTES, PARCOUNT, "basements fetched as a target of a query (bytes)");
272     FT_STATUS_INIT(FT_TOKUTIME_BASEMENTS_FETCHED_NORMAL,      BASEMENTS_FETCHED_TARGET_QUERY_SECONDS, TOKUTIME, "basements fetched as a target of a query (seconds)");
273     FT_STATUS_INIT(FT_NUM_BASEMENTS_FETCHED_AGGRESSIVE,       BASEMENTS_FETCHED_PRELOCKED_RANGE,    PARCOUNT, "basements fetched for prelocked range");
274     FT_STATUS_INIT(FT_BYTES_BASEMENTS_FETCHED_AGGRESSIVE,     BASEMENTS_FETCHED_PRELOCKED_RANGE_BYTES, PARCOUNT, "basements fetched for prelocked range (bytes)");
275     FT_STATUS_INIT(FT_TOKUTIME_BASEMENTS_FETCHED_AGGRESSIVE,  BASEMENTS_FETCHED_PRELOCKED_RANGE_SECONDS, TOKUTIME, "basements fetched for prelocked range (seconds)");
276     FT_STATUS_INIT(FT_NUM_BASEMENTS_FETCHED_PREFETCH,         BASEMENTS_FETCHED_PREFETCH,           PARCOUNT, "basements fetched for prefetch");
277     FT_STATUS_INIT(FT_BYTES_BASEMENTS_FETCHED_PREFETCH,       BASEMENTS_FETCHED_PREFETCH_BYTES,     PARCOUNT, "basements fetched for prefetch (bytes)");
278     FT_STATUS_INIT(FT_TOKUTIME_BASEMENTS_FETCHED_PREFETCH,    BASEMENTS_FETCHED_PREFETCH_SECONDS,   TOKUTIME, "basements fetched for prefetch (seconds)");
279     FT_STATUS_INIT(FT_NUM_BASEMENTS_FETCHED_WRITE,            BASEMENTS_FETCHED_FOR_WRITE,          PARCOUNT, "basements fetched for write");
280     FT_STATUS_INIT(FT_BYTES_BASEMENTS_FETCHED_WRITE,          BASEMENTS_FETCHED_FOR_WRITE_BYTES,    PARCOUNT, "basements fetched for write (bytes)");
281     FT_STATUS_INIT(FT_TOKUTIME_BASEMENTS_FETCHED_WRITE,       BASEMENTS_FETCHED_FOR_WRITE_SECONDS,  TOKUTIME, "basements fetched for write (seconds)");
282     // Buffers: For queries, aggressive fetching in prelocked range, prefetching, or writing.
283     FT_STATUS_INIT(FT_NUM_MSG_BUFFER_FETCHED_NORMAL,          BUFFERS_FETCHED_TARGET_QUERY,         PARCOUNT, "buffers fetched as a target of a query");
284     FT_STATUS_INIT(FT_BYTES_MSG_BUFFER_FETCHED_NORMAL,        BUFFERS_FETCHED_TARGET_QUERY_BYTES,   PARCOUNT, "buffers fetched as a target of a query (bytes)");
285     FT_STATUS_INIT(FT_TOKUTIME_MSG_BUFFER_FETCHED_NORMAL,     BUFFERS_FETCHED_TARGET_QUERY_SECONDS, TOKUTIME, "buffers fetched as a target of a query (seconds)");
286     FT_STATUS_INIT(FT_NUM_MSG_BUFFER_FETCHED_AGGRESSIVE,      BUFFERS_FETCHED_PRELOCKED_RANGE,      PARCOUNT, "buffers fetched for prelocked range");
287     FT_STATUS_INIT(FT_BYTES_MSG_BUFFER_FETCHED_AGGRESSIVE,    BUFFERS_FETCHED_PRELOCKED_RANGE_BYTES, PARCOUNT, "buffers fetched for prelocked range (bytes)");
288     FT_STATUS_INIT(FT_TOKUTIME_MSG_BUFFER_FETCHED_AGGRESSIVE, BUFFERS_FETCHED_PRELOCKED_RANGE_SECONDS, TOKUTIME, "buffers fetched for prelocked range (seconds)");
289     FT_STATUS_INIT(FT_NUM_MSG_BUFFER_FETCHED_PREFETCH,        BUFFERS_FETCHED_PREFETCH,             PARCOUNT, "buffers fetched for prefetch");
290     FT_STATUS_INIT(FT_BYTES_MSG_BUFFER_FETCHED_PREFETCH,      BUFFERS_FETCHED_PREFETCH_BYTES,       PARCOUNT, "buffers fetched for prefetch (bytes)");
291     FT_STATUS_INIT(FT_TOKUTIME_MSG_BUFFER_FETCHED_PREFETCH,   BUFFERS_FETCHED_PREFETCH_SECONDS,     TOKUTIME, "buffers fetched for prefetch (seconds)");
292     FT_STATUS_INIT(FT_NUM_MSG_BUFFER_FETCHED_WRITE,           BUFFERS_FETCHED_FOR_WRITE,            PARCOUNT, "buffers fetched for write");
293     FT_STATUS_INIT(FT_BYTES_MSG_BUFFER_FETCHED_WRITE,         BUFFERS_FETCHED_FOR_WRITE_BYTES,      PARCOUNT, "buffers fetched for write (bytes)");
294     FT_STATUS_INIT(FT_TOKUTIME_MSG_BUFFER_FETCHED_WRITE,      BUFFERS_FETCHED_FOR_WRITE_SECONDS,    TOKUTIME, "buffers fetched for write (seconds)");
295 
296     // Disk write statistics.
297     //
298     // Leaf/Nonleaf: Not for checkpoint
299     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF,                        LEAF_NODES_FLUSHED_NOT_CHECKPOINT,    PARCOUNT, "leaf nodes flushed to disk (not for checkpoint)");
300     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF_BYTES,                  LEAF_NODES_FLUSHED_NOT_CHECKPOINT_BYTES, PARCOUNT, "leaf nodes flushed to disk (not for checkpoint) (bytes)");
301     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF_UNCOMPRESSED_BYTES,     LEAF_NODES_FLUSHED_NOT_CHECKPOINT_UNCOMPRESSED_BYTES, PARCOUNT, "leaf nodes flushed to disk (not for checkpoint) (uncompressed bytes)");
302     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF_TOKUTIME,               LEAF_NODES_FLUSHED_NOT_CHECKPOINT_SECONDS, TOKUTIME, "leaf nodes flushed to disk (not for checkpoint) (seconds)");
303     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF,                     NONLEAF_NODES_FLUSHED_TO_DISK_NOT_CHECKPOINT, PARCOUNT, "nonleaf nodes flushed to disk (not for checkpoint)");
304     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF_BYTES,               NONLEAF_NODES_FLUSHED_TO_DISK_NOT_CHECKPOINT_BYTES, PARCOUNT, "nonleaf nodes flushed to disk (not for checkpoint) (bytes)");
305     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF_UNCOMPRESSED_BYTES,  NONLEAF_NODES_FLUSHED_TO_DISK_NOT_CHECKPOINT_UNCOMPRESSED_BYTES, PARCOUNT, "nonleaf nodes flushed to disk (not for checkpoint) (uncompressed bytes)");
306     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF_TOKUTIME,            NONLEAF_NODES_FLUSHED_TO_DISK_NOT_CHECKPOINT_SECONDS, TOKUTIME, "nonleaf nodes flushed to disk (not for checkpoint) (seconds)");
307     // Leaf/Nonleaf: For checkpoint
308     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF_FOR_CHECKPOINT,         LEAF_NODES_FLUSHED_CHECKPOINT,        PARCOUNT, "leaf nodes flushed to disk (for checkpoint)");
309     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF_BYTES_FOR_CHECKPOINT,   LEAF_NODES_FLUSHED_CHECKPOINT_BYTES,  PARCOUNT, "leaf nodes flushed to disk (for checkpoint) (bytes)");
310     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF_UNCOMPRESSED_BYTES_FOR_CHECKPOINT, LEAF_NODES_FLUSHED_CHECKPOINT_UNCOMPRESSED_BYTES, PARCOUNT, "leaf nodes flushed to disk (for checkpoint) (uncompressed bytes)");
311     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF_TOKUTIME_FOR_CHECKPOINT, LEAF_NODES_FLUSHED_CHECKPOINT_SECONDS, TOKUTIME, "leaf nodes flushed to disk (for checkpoint) (seconds)");
312     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF_FOR_CHECKPOINT,      NONLEAF_NODES_FLUSHED_TO_DISK_CHECKPOINT, PARCOUNT, "nonleaf nodes flushed to disk (for checkpoint)");
313     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF_BYTES_FOR_CHECKPOINT, NONLEAF_NODES_FLUSHED_TO_DISK_CHECKPOINT_BYTES, PARCOUNT, "nonleaf nodes flushed to disk (for checkpoint) (bytes)");
314     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF_UNCOMPRESSED_BYTES_FOR_CHECKPOINT, NONLEAF_NODES_FLUSHED_TO_DISK_CHECKPOINT_UNCOMPRESSED_BYTES, PARCOUNT, "nonleaf nodes flushed to disk (for checkpoint) (uncompressed bytes)");
315     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF_TOKUTIME_FOR_CHECKPOINT, NONLEAF_NODES_FLUSHED_TO_DISK_CHECKPOINT_SECONDS, TOKUTIME, "nonleaf nodes flushed to disk (for checkpoint) (seconds)");
316     FT_STATUS_INIT(FT_DISK_FLUSH_LEAF_COMPRESSION_RATIO,      LEAF_NODE_COMPRESSION_RATIO,          DOUBLE, "uncompressed / compressed bytes written (leaf)");
317     FT_STATUS_INIT(FT_DISK_FLUSH_NONLEAF_COMPRESSION_RATIO,   NONLEAF_NODE_COMPRESSION_RATIO,       DOUBLE, "uncompressed / compressed bytes written (nonleaf)");
318     FT_STATUS_INIT(FT_DISK_FLUSH_OVERALL_COMPRESSION_RATIO,   OVERALL_NODE_COMPRESSION_RATIO,       DOUBLE, "uncompressed / compressed bytes written (overall)");
319 
320     // CPU time statistics for [de]serialization and [de]compression.
321     FT_STATUS_INIT(FT_LEAF_COMPRESS_TOKUTIME,                 LEAF_COMPRESSION_TO_MEMORY_SECONDS,   TOKUTIME, "leaf compression to memory (seconds)");
322     FT_STATUS_INIT(FT_LEAF_SERIALIZE_TOKUTIME,                LEAF_SERIALIZATION_TO_MEMORY_SECONDS, TOKUTIME, "leaf serialization to memory (seconds)");
323     FT_STATUS_INIT(FT_LEAF_DECOMPRESS_TOKUTIME,               LEAF_DECOMPRESSION_TO_MEMORY_SECONDS, TOKUTIME, "leaf decompression to memory (seconds)");
324     FT_STATUS_INIT(FT_LEAF_DESERIALIZE_TOKUTIME,              LEAF_DESERIALIZATION_TO_MEMORY_SECONDS, TOKUTIME, "leaf deserialization to memory (seconds)");
325     FT_STATUS_INIT(FT_NONLEAF_COMPRESS_TOKUTIME,              NONLEAF_COMPRESSION_TO_MEMORY_SECONDS, TOKUTIME, "nonleaf compression to memory (seconds)");
326     FT_STATUS_INIT(FT_NONLEAF_SERIALIZE_TOKUTIME,             NONLEAF_SERIALIZATION_TO_MEMORY_SECONDS, TOKUTIME, "nonleaf serialization to memory (seconds)");
327     FT_STATUS_INIT(FT_NONLEAF_DECOMPRESS_TOKUTIME,            NONLEAF_DECOMPRESSION_TO_MEMORY_SECONDS, TOKUTIME, "nonleaf decompression to memory (seconds)");
328     FT_STATUS_INIT(FT_NONLEAF_DESERIALIZE_TOKUTIME,           NONLEAF_DESERIALIZATION_TO_MEMORY_SECONDS, TOKUTIME, "nonleaf deserialization to memory (seconds)");
329 
330     // Promotion statistics.
331     FT_STATUS_INIT(FT_PRO_NUM_ROOT_SPLIT,                     PROMOTION_ROOTS_SPLIT,                PARCOUNT, "promotion: roots split");
332     FT_STATUS_INIT(FT_PRO_NUM_ROOT_H0_INJECT,                 PROMOTION_LEAF_ROOTS_INJECTED_INTO,   PARCOUNT, "promotion: leaf roots injected into");
333     FT_STATUS_INIT(FT_PRO_NUM_ROOT_H1_INJECT,                 PROMOTION_H1_ROOTS_INJECTED_INTO,     PARCOUNT, "promotion: h1 roots injected into");
334     FT_STATUS_INIT(FT_PRO_NUM_INJECT_DEPTH_0,                 PROMOTION_INJECTIONS_AT_DEPTH_0,      PARCOUNT, "promotion: injections at depth 0");
335     FT_STATUS_INIT(FT_PRO_NUM_INJECT_DEPTH_1,                 PROMOTION_INJECTIONS_AT_DEPTH_1,      PARCOUNT, "promotion: injections at depth 1");
336     FT_STATUS_INIT(FT_PRO_NUM_INJECT_DEPTH_2,                 PROMOTION_INJECTIONS_AT_DEPTH_2,      PARCOUNT, "promotion: injections at depth 2");
337     FT_STATUS_INIT(FT_PRO_NUM_INJECT_DEPTH_3,                 PROMOTION_INJECTIONS_AT_DEPTH_3,      PARCOUNT, "promotion: injections at depth 3");
338     FT_STATUS_INIT(FT_PRO_NUM_INJECT_DEPTH_GT3,               PROMOTION_INJECTIONS_LOWER_THAN_DEPTH_3, PARCOUNT, "promotion: injections lower than depth 3");
339     FT_STATUS_INIT(FT_PRO_NUM_STOP_NONEMPTY_BUF,              PROMOTION_STOPPED_NONEMPTY_BUFFER,    PARCOUNT, "promotion: stopped because of a nonempty buffer");
340     FT_STATUS_INIT(FT_PRO_NUM_STOP_H1,                        PROMOTION_STOPPED_AT_HEIGHT_1,        PARCOUNT, "promotion: stopped at height 1");
341     FT_STATUS_INIT(FT_PRO_NUM_STOP_LOCK_CHILD,                PROMOTION_STOPPED_CHILD_LOCKED_OR_NOT_IN_MEMORY, PARCOUNT, "promotion: stopped because the child was locked or not at all in memory");
342     FT_STATUS_INIT(FT_PRO_NUM_STOP_CHILD_INMEM,               PROMOTION_STOPPED_CHILD_NOT_FULLY_IN_MEMORY, PARCOUNT, "promotion: stopped because the child was not fully in memory");
343     FT_STATUS_INIT(FT_PRO_NUM_DIDNT_WANT_PROMOTE,             PROMOTION_STOPPED_AFTER_LOCKING_CHILD, PARCOUNT, "promotion: stopped anyway, after locking the child");
344     FT_STATUS_INIT(FT_BASEMENT_DESERIALIZE_FIXED_KEYSIZE,     BASEMENT_DESERIALIZATION_FIXED_KEY,   PARCOUNT, "basement nodes deserialized with fixed-keysize");
345     FT_STATUS_INIT(FT_BASEMENT_DESERIALIZE_VARIABLE_KEYSIZE,  BASEMENT_DESERIALIZATION_VARIABLE_KEY, PARCOUNT, "basement nodes deserialized with variable-keysize");
346     FT_STATUS_INIT(FT_PRO_RIGHTMOST_LEAF_SHORTCUT_SUCCESS,    PRO_RIGHTMOST_LEAF_SHORTCUT_SUCCESS,  PARCOUNT, "promotion: succeeded in using the rightmost leaf shortcut");
347     FT_STATUS_INIT(FT_PRO_RIGHTMOST_LEAF_SHORTCUT_FAIL_POS,   PRO_RIGHTMOST_LEAF_SHORTCUT_FAIL_POS, PARCOUNT, "promotion: tried the rightmost leaf shorcut but failed (out-of-bounds)");
348     FT_STATUS_INIT(FT_PRO_RIGHTMOST_LEAF_SHORTCUT_FAIL_REACTIVE,RIGHTMOST_LEAF_SHORTCUT_FAIL_REACTIVE, PARCOUNT, "promotion: tried the rightmost leaf shorcut but failed (child reactive)");
349 
350     FT_STATUS_INIT(FT_CURSOR_SKIP_DELETED_LEAF_ENTRY,         CURSOR_SKIP_DELETED_LEAF_ENTRY,       PARCOUNT, "cursor skipped deleted leaf entries");
351 
352     m_initialized = true;
353 #undef FT_STATUS_INIT
354 }
destroy()355 void FT_STATUS_S::destroy() {
356     if (!m_initialized) return;
357     for (int i = 0; i < FT_STATUS_NUM_ROWS; ++i) {
358         if (status[i].type == PARCOUNT) {
359             destroy_partitioned_counter(status[i].value.parcount);
360         }
361     }
362 }
363 
364 
365 
366 FT_FLUSHER_STATUS_S fl_status;
init()367 void FT_FLUSHER_STATUS_S::init() {
368     if (m_initialized) return;
369 #define FL_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "ft flusher: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
370     FL_STATUS_INIT(FT_FLUSHER_CLEANER_TOTAL_NODES,                 FLUSHER_CLEANER_TOTAL_NODES,                 UINT64, "total nodes potentially flushed by cleaner thread");
371     FL_STATUS_INIT(FT_FLUSHER_CLEANER_H1_NODES,                    FLUSHER_CLEANER_H1_NODES,                    UINT64, "height-one nodes flushed by cleaner thread");
372     FL_STATUS_INIT(FT_FLUSHER_CLEANER_HGT1_NODES,                  FLUSHER_CLEANER_HGT1_NODES,                  UINT64, "height-greater-than-one nodes flushed by cleaner thread");
373     FL_STATUS_INIT(FT_FLUSHER_CLEANER_EMPTY_NODES,                 FLUSHER_CLEANER_EMPTY_NODES,                 UINT64, "nodes cleaned which had empty buffers");
374     FL_STATUS_INIT(FT_FLUSHER_CLEANER_NODES_DIRTIED,               FLUSHER_CLEANER_NODES_DIRTIED,               UINT64, "nodes dirtied by cleaner thread");
375     FL_STATUS_INIT(FT_FLUSHER_CLEANER_MAX_BUFFER_SIZE,             FLUSHER_CLEANER_MAX_BUFFER_SIZE,             UINT64, "max bytes in a buffer flushed by cleaner thread");
376     FL_STATUS_INIT(FT_FLUSHER_CLEANER_MIN_BUFFER_SIZE,             FLUSHER_CLEANER_MIN_BUFFER_SIZE,             UINT64, "min bytes in a buffer flushed by cleaner thread");
377     FL_STATUS_INIT(FT_FLUSHER_CLEANER_TOTAL_BUFFER_SIZE,           FLUSHER_CLEANER_TOTAL_BUFFER_SIZE,           UINT64, "total bytes in buffers flushed by cleaner thread");
378     FL_STATUS_INIT(FT_FLUSHER_CLEANER_MAX_BUFFER_WORKDONE,         FLUSHER_CLEANER_MAX_BUFFER_WORKDONE,         UINT64, "max workdone in a buffer flushed by cleaner thread");
379     FL_STATUS_INIT(FT_FLUSHER_CLEANER_MIN_BUFFER_WORKDONE,         FLUSHER_CLEANER_MIN_BUFFER_WORKDONE,         UINT64, "min workdone in a buffer flushed by cleaner thread");
380     FL_STATUS_INIT(FT_FLUSHER_CLEANER_TOTAL_BUFFER_WORKDONE,       FLUSHER_CLEANER_TOTAL_BUFFER_WORKDONE,       UINT64, "total workdone in buffers flushed by cleaner thread");
381     FL_STATUS_INIT(FT_FLUSHER_CLEANER_NUM_LEAF_MERGES_STARTED,     FLUSHER_CLEANER_NUM_LEAF_MERGES_STARTED,     UINT64, "times cleaner thread tries to merge a leaf");
382     FL_STATUS_INIT(FT_FLUSHER_CLEANER_NUM_LEAF_MERGES_RUNNING,     FLUSHER_CLEANER_NUM_LEAF_MERGES_RUNNING,     UINT64, "cleaner thread leaf merges in progress");
383     FL_STATUS_INIT(FT_FLUSHER_CLEANER_NUM_LEAF_MERGES_COMPLETED,   FLUSHER_CLEANER_NUM_LEAF_MERGES_COMPLETED,   UINT64, "cleaner thread leaf merges successful");
384     FL_STATUS_INIT(FT_FLUSHER_CLEANER_NUM_DIRTIED_FOR_LEAF_MERGE,  FLUSHER_CLEANER_NUM_DIRTIED_FOR_LEAF_MERGE,  UINT64, "nodes dirtied by cleaner thread leaf merges");
385     FL_STATUS_INIT(FT_FLUSHER_FLUSH_TOTAL,                         FLUSHER_FLUSH_TOTAL,                         UINT64, "total number of flushes done by flusher threads or cleaner threads");
386     FL_STATUS_INIT(FT_FLUSHER_FLUSH_IN_MEMORY,                     FLUSHER_FLUSH_IN_MEMORY,                     UINT64, "number of in memory flushes");
387     FL_STATUS_INIT(FT_FLUSHER_FLUSH_NEEDED_IO,                     FLUSHER_FLUSH_NEEDED_IO,                     UINT64, "number of flushes that read something off disk");
388     FL_STATUS_INIT(FT_FLUSHER_FLUSH_CASCADES,                      FLUSHER_FLUSH_CASCADES,                      UINT64, "number of flushes that triggered another flush in child");
389     FL_STATUS_INIT(FT_FLUSHER_FLUSH_CASCADES_1,                    FLUSHER_FLUSH_CASCADES_1,                    UINT64, "number of flushes that triggered 1 cascading flush");
390     FL_STATUS_INIT(FT_FLUSHER_FLUSH_CASCADES_2,                    FLUSHER_FLUSH_CASCADES_2,                    UINT64, "number of flushes that triggered 2 cascading flushes");
391     FL_STATUS_INIT(FT_FLUSHER_FLUSH_CASCADES_3,                    FLUSHER_FLUSH_CASCADES_3,                    UINT64, "number of flushes that triggered 3 cascading flushes");
392     FL_STATUS_INIT(FT_FLUSHER_FLUSH_CASCADES_4,                    FLUSHER_FLUSH_CASCADES_4,                    UINT64, "number of flushes that triggered 4 cascading flushes");
393     FL_STATUS_INIT(FT_FLUSHER_FLUSH_CASCADES_5,                    FLUSHER_FLUSH_CASCADES_5,                    UINT64, "number of flushes that triggered 5 cascading flushes");
394     FL_STATUS_INIT(FT_FLUSHER_FLUSH_CASCADES_GT_5,                 FLUSHER_FLUSH_CASCADES_GT_5,                 UINT64, "number of flushes that triggered over 5 cascading flushes");
395     FL_STATUS_INIT(FT_FLUSHER_SPLIT_LEAF,                          FLUSHER_SPLIT_LEAF,                          UINT64, "leaf node splits");
396     FL_STATUS_INIT(FT_FLUSHER_SPLIT_NONLEAF,                       FLUSHER_SPLIT_NONLEAF,                       UINT64, "nonleaf node splits");
397     FL_STATUS_INIT(FT_FLUSHER_MERGE_LEAF,                          FLUSHER_MERGE_LEAF,                          UINT64, "leaf node merges");
398     FL_STATUS_INIT(FT_FLUSHER_MERGE_NONLEAF,                       FLUSHER_MERGE_NONLEAF,                       UINT64, "nonleaf node merges");
399     FL_STATUS_INIT(FT_FLUSHER_BALANCE_LEAF,                        FLUSHER_BALANCE_LEAF,                        UINT64, "leaf node balances");
400 
401     FL_STATUS_VAL(FT_FLUSHER_CLEANER_MIN_BUFFER_SIZE) = UINT64_MAX;
402     FL_STATUS_VAL(FT_FLUSHER_CLEANER_MIN_BUFFER_WORKDONE) = UINT64_MAX;
403 
404     m_initialized = true;
405 #undef FL_STATUS_INIT
406 }
destroy()407 void FT_FLUSHER_STATUS_S::destroy() {
408     if (!m_initialized) return;
409     for (int i = 0; i < FT_FLUSHER_STATUS_NUM_ROWS; ++i) {
410         if (status[i].type == PARCOUNT) {
411             destroy_partitioned_counter(status[i].value.parcount);
412         }
413     }
414 }
415 
416 
417 
418 FT_HOT_STATUS_S hot_status;
init()419 void FT_HOT_STATUS_S::init() {
420     if (m_initialized) return;
421 #define HOT_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "hot: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
422     HOT_STATUS_INIT(FT_HOT_NUM_STARTED,           HOT_NUM_STARTED,           UINT64, "operations ever started");
423     HOT_STATUS_INIT(FT_HOT_NUM_COMPLETED,         HOT_NUM_COMPLETED,         UINT64, "operations successfully completed");
424     HOT_STATUS_INIT(FT_HOT_NUM_ABORTED,           HOT_NUM_ABORTED,           UINT64, "operations aborted");
425     HOT_STATUS_INIT(FT_HOT_MAX_ROOT_FLUSH_COUNT,  HOT_MAX_ROOT_FLUSH_COUNT,  UINT64, "max number of flushes from root ever required to optimize a tree");
426 
427     m_initialized = true;
428 #undef HOT_STATUS_INIT
429 }
destroy()430 void FT_HOT_STATUS_S::destroy() {
431     if (!m_initialized) return;
432     for (int i = 0; i < FT_HOT_STATUS_NUM_ROWS; ++i) {
433         if (status[i].type == PARCOUNT) {
434             destroy_partitioned_counter(status[i].value.parcount);
435         }
436     }
437 }
438 
439 
440 
441 TXN_STATUS_S txn_status;
init()442 void TXN_STATUS_S::init() {
443     if (m_initialized) return;
444 #define TXN_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "txn: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
445     TXN_STATUS_INIT(TXN_BEGIN,          TXN_BEGIN,              PARCOUNT, "begin");
446     TXN_STATUS_INIT(TXN_READ_BEGIN,     TXN_BEGIN_READ_ONLY,    PARCOUNT, "begin read only");
447     TXN_STATUS_INIT(TXN_COMMIT,         TXN_COMMITS,            PARCOUNT, "successful commits");
448     TXN_STATUS_INIT(TXN_ABORT,          TXN_ABORTS,             PARCOUNT, "aborts");
449     m_initialized = true;
450 #undef TXN_STATUS_INIT
451 }
destroy()452 void TXN_STATUS_S::destroy() {
453     if (!m_initialized) return;
454     for (int i = 0; i < TXN_STATUS_NUM_ROWS; ++i) {
455         if (status[i].type == PARCOUNT) {
456             destroy_partitioned_counter(status[i].value.parcount);
457         }
458     }
459 }
460 
461 
462 LOGGER_STATUS_S log_status;
init()463 void LOGGER_STATUS_S::init() {
464     if (m_initialized) return;
465 #define LOG_STATUS_INIT(k,c,t,l) TOKUFT_STATUS_INIT((*this), k, c, t, "logger: " l, TOKU_ENGINE_STATUS|TOKU_GLOBAL_STATUS)
466     LOG_STATUS_INIT(LOGGER_NEXT_LSN,                    LOGGER_NEXT_LSN,        UINT64,  "next LSN");
467     LOG_STATUS_INIT(LOGGER_NUM_WRITES,                  LOGGER_WRITES,          UINT64, "writes");
468     LOG_STATUS_INIT(LOGGER_BYTES_WRITTEN,               LOGGER_WRITES_BYTES,    UINT64, "writes (bytes)");
469     LOG_STATUS_INIT(LOGGER_UNCOMPRESSED_BYTES_WRITTEN,  LOGGER_WRITES_UNCOMPRESSED_BYTES, UINT64, "writes (uncompressed bytes)");
470     LOG_STATUS_INIT(LOGGER_TOKUTIME_WRITES,             LOGGER_WRITES_SECONDS,  TOKUTIME, "writes (seconds)");
471     LOG_STATUS_INIT(LOGGER_WAIT_BUF_LONG,               LOGGER_WAIT_LONG,       UINT64, "number of long logger write operations");
472     m_initialized = true;
473 #undef LOG_STATUS_INIT
474 }
destroy()475 void LOGGER_STATUS_S::destroy() {
476     if (!m_initialized) return;
477     for (int i = 0; i < LOGGER_STATUS_NUM_ROWS; ++i) {
478         if (status[i].type == PARCOUNT) {
479             destroy_partitioned_counter(status[i].value.parcount);
480         }
481     }
482 }
483 
toku_status_init(void)484 void toku_status_init(void) {
485     le_status.init();
486     cp_status.init();
487     ltm_status.init();
488     ft_status.init();
489     fl_status.init();
490     hot_status.init();
491     txn_status.init();
492     log_status.init();
493 }
toku_status_destroy(void)494 void toku_status_destroy(void) {
495     log_status.destroy();
496     txn_status.destroy();
497     hot_status.destroy();
498     fl_status.destroy();
499     ft_status.destroy();
500     ltm_status.destroy();
501     cp_status.destroy();
502     le_status.destroy();
503 }
504