1 | /* Copyright (c) 2017, Percona and/or its affiliates. All rights reserved. |
2 | |
3 | This program is free software; you can redistribute it and/or modify |
4 | it under the terms of the GNU General Public License as published by |
5 | the Free Software Foundation; version 2 of the License. |
6 | |
7 | This program is distributed in the hope that it will be useful, |
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | GNU General Public License for more details. |
11 | |
12 | You should have received a copy of the GNU General Public License |
13 | along with this program; if not, write to the Free Software |
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
15 | |
16 | #ifdef USE_PRAGMA_IMPLEMENTATION |
17 | #pragma implementation // gcc: Class implementation |
18 | #endif |
19 | |
20 | #define MYSQL_SERVER 1 |
21 | |
22 | /* The C++ file's header */ |
23 | #include "./rdb_psi.h" |
24 | |
25 | /* MySQL header files */ |
26 | #include <mysql/psi/mysql_stage.h> |
27 | |
28 | namespace myrocks { |
29 | |
30 | /* |
31 | The following is needed as an argument for mysql_stage_register, |
32 | irrespectively of whether we're compiling with P_S or not. |
33 | */ |
34 | my_core::PSI_stage_info stage_waiting_on_row_lock = {0, "Waiting for row lock" , |
35 | 0}; |
36 | |
37 | #ifdef HAVE_PSI_INTERFACE |
38 | my_core::PSI_stage_info *all_rocksdb_stages[] = {&stage_waiting_on_row_lock}; |
39 | |
40 | my_core::PSI_thread_key rdb_background_psi_thread_key, |
41 | rdb_drop_idx_psi_thread_key; |
42 | |
43 | my_core::PSI_thread_info all_rocksdb_threads[] = { |
44 | {&rdb_background_psi_thread_key, "background" , PSI_FLAG_GLOBAL}, |
45 | {&rdb_drop_idx_psi_thread_key, "drop index" , PSI_FLAG_GLOBAL}, |
46 | }; |
47 | |
48 | my_core::PSI_mutex_key rdb_psi_open_tbls_mutex_key, rdb_signal_bg_psi_mutex_key, |
49 | rdb_signal_drop_idx_psi_mutex_key, rdb_collation_data_mutex_key, |
50 | rdb_mem_cmp_space_mutex_key, key_mutex_tx_list, rdb_sysvars_psi_mutex_key, |
51 | rdb_cfm_mutex_key, rdb_sst_commit_key; |
52 | |
53 | my_core::PSI_mutex_info all_rocksdb_mutexes[] = { |
54 | {&rdb_psi_open_tbls_mutex_key, "open tables" , PSI_FLAG_GLOBAL}, |
55 | {&rdb_signal_bg_psi_mutex_key, "stop background" , PSI_FLAG_GLOBAL}, |
56 | {&rdb_signal_drop_idx_psi_mutex_key, "signal drop index" , PSI_FLAG_GLOBAL}, |
57 | {&rdb_collation_data_mutex_key, "collation data init" , PSI_FLAG_GLOBAL}, |
58 | {&rdb_mem_cmp_space_mutex_key, "collation space char data init" , |
59 | PSI_FLAG_GLOBAL}, |
60 | {&key_mutex_tx_list, "tx_list" , PSI_FLAG_GLOBAL}, |
61 | {&rdb_sysvars_psi_mutex_key, "setting sysvar" , PSI_FLAG_GLOBAL}, |
62 | {&rdb_cfm_mutex_key, "column family manager" , PSI_FLAG_GLOBAL}, |
63 | {&rdb_sst_commit_key, "sst commit" , PSI_FLAG_GLOBAL}, |
64 | }; |
65 | |
66 | my_core::PSI_rwlock_key key_rwlock_collation_exception_list, |
67 | key_rwlock_read_free_rpl_tables, key_rwlock_skip_unique_check_tables; |
68 | |
69 | my_core::PSI_rwlock_info all_rocksdb_rwlocks[] = { |
70 | {&key_rwlock_collation_exception_list, "collation_exception_list" , |
71 | PSI_FLAG_GLOBAL}, |
72 | {&key_rwlock_read_free_rpl_tables, "read_free_rpl_tables" , PSI_FLAG_GLOBAL}, |
73 | {&key_rwlock_skip_unique_check_tables, "skip_unique_check_tables" , |
74 | PSI_FLAG_GLOBAL}, |
75 | }; |
76 | |
77 | my_core::PSI_cond_key rdb_signal_bg_psi_cond_key, |
78 | rdb_signal_drop_idx_psi_cond_key; |
79 | |
80 | my_core::PSI_cond_info all_rocksdb_conds[] = { |
81 | {&rdb_signal_bg_psi_cond_key, "cond signal background" , PSI_FLAG_GLOBAL}, |
82 | {&rdb_signal_drop_idx_psi_cond_key, "cond signal drop index" , |
83 | PSI_FLAG_GLOBAL}, |
84 | }; |
85 | |
86 | void init_rocksdb_psi_keys() { |
87 | const char *const category = "rocksdb" ; |
88 | int count; |
89 | |
90 | if (PSI_server == nullptr) |
91 | return; |
92 | |
93 | count = array_elements(all_rocksdb_mutexes); |
94 | PSI_server->register_mutex(category, all_rocksdb_mutexes, count); |
95 | |
96 | count = array_elements(all_rocksdb_rwlocks); |
97 | PSI_server->register_rwlock(category, all_rocksdb_rwlocks, count); |
98 | |
99 | count = array_elements(all_rocksdb_conds); |
100 | //TODO Disabling PFS for conditions due to the bug |
101 | // https://github.com/MySQLOnRocksDB/mysql-5.6/issues/92 |
102 | // PSI_server->register_cond(category, all_rocksdb_conds, count); |
103 | |
104 | count = array_elements(all_rocksdb_stages); |
105 | mysql_stage_register(category, all_rocksdb_stages, count); |
106 | |
107 | count = array_elements(all_rocksdb_threads); |
108 | mysql_thread_register(category, all_rocksdb_threads, count); |
109 | } |
110 | #else // HAVE_PSI_INTERFACE |
111 | void init_rocksdb_psi_keys() {} |
112 | #endif // HAVE_PSI_INTERFACE |
113 | |
114 | } // namespace myrocks |
115 | |