MySQL 8.0.29
Source Code Documentation
pfs_host.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
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, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program 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, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef PFS_HOST_H
25#define PFS_HOST_H
26
27/**
28 @file storage/perfschema/pfs_host.h
29 Performance schema host (declarations).
30*/
31
32#include <sys/types.h>
33#include <atomic>
34
35#include "lf.h"
36#include "my_hostname.h" /* HOSTNAME_LENGTH */
37#include "my_inttypes.h"
38#include "mysql_com.h"
43
44struct PFS_global_param;
48struct PFS_thread;
49
50/**
51 @addtogroup performance_schema_buffers
52 @{
53*/
54
55/** Hash key for a host. */
57 /** Host name. */
59};
60
61/** Per host statistics. */
63 public:
64 inline void init_refcount(void) { m_refcount.store(1); }
65
66 inline int get_refcount(void) { return m_refcount.load(); }
67
68 inline void inc_refcount(void) { ++m_refcount; }
69
70 inline void dec_refcount(void) { --m_refcount; }
71
72 void aggregate(bool alive);
73 void aggregate_waits(void);
74 void aggregate_stages(void);
75 void aggregate_statements(void);
76 void aggregate_transactions(void);
77 void aggregate_errors(void);
78 void aggregate_memory(bool alive);
79 void aggregate_status(void);
80 void aggregate_stats(void);
81 void release(void);
82
83 /** Reset all memory statistics. */
84 void rebase_memory_stats();
85
86 void carry_memory_stat_alloc_delta(PFS_memory_stat_alloc_delta *delta,
87 uint index);
88 void carry_memory_stat_free_delta(PFS_memory_stat_free_delta *delta,
89 uint index);
90
92 m_has_memory_stats = false;
93 m_instr_class_memory_stats = array;
94 }
95
97 if (!m_has_memory_stats) {
98 return nullptr;
99 }
100 return m_instr_class_memory_stats;
101 }
102
104 if (!m_has_memory_stats) {
105 rebase_memory_stats();
106 m_has_memory_stats = true;
107 }
108 return m_instr_class_memory_stats;
109 }
110
111 /* Internal lock. */
114
116
117 private:
118 std::atomic<int> m_refcount;
119
120 /**
121 Per host memory aggregated statistics.
122 This member holds the data for the table
123 PERFORMANCE_SCHEMA.MEMORY_SUMMARY_BY_HOST_BY_EVENT_NAME.
124 Immutable, safe to use without internal lock.
125 */
127};
128
129int init_host(const PFS_global_param *param);
130void cleanup_host(void);
131int init_host_hash(const PFS_global_param *param);
132void cleanup_host_hash(void);
133
135
137void purge_all_host(void);
138
139/* For show status. */
140
141extern LF_HASH host_hash;
142
143/** @} */
144#endif
void cleanup_host_hash(void)
Cleanup the host hash.
Definition: pfs_host.cc:133
PFS_host * sanitize_host(PFS_host *unsafe)
Definition: pfs_host.cc:347
int init_host_hash(const PFS_global_param *param)
Initialize the host hash.
Definition: pfs_host.cc:122
void cleanup_host(void)
Cleanup all the host buffers.
Definition: pfs_host.cc:66
int init_host(const PFS_global_param *param)
Initialize the host buffers.
Definition: pfs_host.cc:57
LF_HASH host_hash
Definition: pfs_host.cc:49
void purge_all_host(void)
Purge non connected hosts, reset stats of connected hosts.
Definition: pfs_host.cc:388
PFS_host * find_or_create_host(PFS_thread *thread, const PFS_host_name *host)
Definition: pfs_host.cc:154
Common definition used by mysys, performance schema and server & client.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Common definition between mysql server & client.
const char * host
Definition: mysqladmin.cc:58
Performance schema connection slice (declarations).
Miscellaneous global dependencies (declarations).
#define PFS_ALIGNED
Definition: pfs_global.h:54
Performance schema internal locks (declarations).
Object names (declarations).
Definition: lf.h:184
A connection slice, an arbitrary grouping of several connections.
Definition: pfs_con_slice.h:53
Performance schema global sizing parameters.
Definition: pfs_server.h:112
Hash key for a host.
Definition: pfs_host.h:56
PFS_host_name m_host_name
Host name.
Definition: pfs_host.h:58
Definition: pfs_name.h:241
Per host statistics.
Definition: pfs_host.h:62
PFS_host_key m_key
Definition: pfs_host.h:113
pfs_lock m_lock
Definition: pfs_host.h:112
PFS_memory_shared_stat * write_instr_class_memory_stats()
Definition: pfs_host.h:103
PFS_memory_shared_stat * m_instr_class_memory_stats
Per host memory aggregated statistics.
Definition: pfs_host.h:126
void set_instr_class_memory_stats(PFS_memory_shared_stat *array)
Definition: pfs_host.h:91
void inc_refcount(void)
Definition: pfs_host.h:68
ulonglong m_disconnected_count
Definition: pfs_host.h:115
const PFS_memory_shared_stat * read_instr_class_memory_stats() const
Definition: pfs_host.h:96
void dec_refcount(void)
Definition: pfs_host.h:70
int get_refcount(void)
Definition: pfs_host.h:66
void init_refcount(void)
Definition: pfs_host.h:64
std::atomic< int > m_refcount
Definition: pfs_host.h:118
Definition: pfs_stat.h:919
Definition: pfs_stat.h:865
Definition: pfs_stat.h:870
Instrumented thread implementation.
Definition: pfs_instr.h:372
A 'lock' protecting performance schema internal buffers.
Definition: pfs_lock.h:151
unsigned int uint
Definition: uca-dump.cc:29
static void alive(server *s)
Definition: xcom_transport.cc:159