MySQL 26.10.0
Source Code Documentation
health_monitor_process_memory_mapping.h
Go to the documentation of this file.
1/* Copyright (c) 2026, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#pragma once
25
27
28#include <cstdint>
29#include <utility>
30
32
33namespace hm {
34
35/**
36 Convert a process memory snapshot into a Health Monitor memory record.
37
38 Identity and residency must have available System_result values. The details
39 and page_faults fields are optional. Optional fields without available values
40 become SQL NULL.
41
42 @param[in] snapshot Process memory snapshot to convert
43 @param[in,out] output Destination record, unchanged on failure
44 @return true on success, false on failure
45*/
48 Process_Memory_Info &output);
49
50/**
51 Check whether the process memory row must be omitted as unavailable.
52
53 The collector omits the row only when every capability is unavailable.
54 Failed capabilities remain failures.
55
56 @param[in] snapshot Process memory snapshot
57 @return true when the complete row is unavailable
58*/
61
63 time_t m_timestamp{0};
64 std::string m_name;
65 uint64_t m_pid{0};
66 uint64_t m_vmrss_bytes{0};
67 uint64_t m_vmdata_bytes{0};
68 uint64_t m_vmswap_bytes{0};
69 uint64_t m_page_faults{0};
73};
74
75/**
76 Convert a process memory record into a Performance Schema table row.
77
78 @param[in] record Process memory record to convert
79 @return Converted table row
80*/
81Health_process_memory_row make_health_process_memory_row(
82 const Process_Memory_Info &record);
83
84/**
85 Determine whether a process memory column is NULL.
86
87 @param[in] row Table row
88 @param[in] index Performance Schema column index
89 @return true when the column is NULL
90*/
91bool health_process_memory_column_is_null(const Health_process_memory_row &row,
92 unsigned int index);
93
99};
100
101/**
102 Deliver one available process memory metric.
103
104 The delivery function receives the metric value and process ID. It is not
105 called when the metric is unavailable. A value of zero is a valid available
106 measurement.
107
108 @param[in] record process memory record
109 @param[in] metric Metric to deliver
110 @param[in] delivery Delivery function
111 @return true when the delivery function was called
112*/
113template <typename Delivery>
115 const Process_memory_metric metric,
116 Delivery &&delivery) {
117 uint64_t value{0};
118 switch (metric) {
120 if (!record.m_residency_available) return false;
121 value = record.m_vmrss_bytes;
122 break;
124 if (!record.m_details_available) return false;
125 value = record.m_vmdata_bytes;
126 break;
128 if (!record.m_details_available) return false;
129 value = record.m_vmswap_bytes;
130 break;
132 if (!record.m_page_faults_available) return false;
133 value = record.m_page_faults;
134 break;
135 }
136
137 std::forward<Delivery>(delivery)(value, record.m_pid);
138 return true;
139}
140
141} // namespace hm
static int record
Definition: mysqltest.cc:195
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
Definition: component_command.h:29
bool convert_process_memory_snapshot(const mysql::system_info::Process_memory_snapshot &snapshot, Process_Memory_Info &output)
Convert a process memory snapshot into a Health Monitor memory record.
Definition: health_monitor_process_memory_mapping.cc:37
Health_process_memory_row make_health_process_memory_row(const Process_Memory_Info &record)
Convert a process memory record into a Performance Schema table row.
Definition: health_monitor_process_memory_mapping.cc:80
Process_memory_metric
Definition: health_monitor_process_memory_mapping.h:94
bool process_memory_snapshot_is_unavailable(const mysql::system_info::Process_memory_snapshot &snapshot)
Check whether the process memory row must be omitted as unavailable.
Definition: health_monitor_process_memory_mapping.cc:69
bool health_process_memory_column_is_null(const Health_process_memory_row &row, const unsigned int index)
Determine whether a process memory column is NULL.
Definition: health_monitor_process_memory_mapping.cc:96
bool deliver_process_memory_metric(const Process_Memory_Info &record, const Process_memory_metric metric, Delivery &&delivery)
Deliver one available process memory metric.
Definition: health_monitor_process_memory_mapping.h:114
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
Definition: health_monitor_process_memory_mapping.h:62
uint64_t m_pid
Definition: health_monitor_process_memory_mapping.h:65
bool m_residency_available
Definition: health_monitor_process_memory_mapping.h:70
time_t m_timestamp
Definition: health_monitor_process_memory_mapping.h:63
uint64_t m_vmswap_bytes
Definition: health_monitor_process_memory_mapping.h:68
bool m_page_faults_available
Definition: health_monitor_process_memory_mapping.h:72
uint64_t m_vmdata_bytes
Definition: health_monitor_process_memory_mapping.h:67
uint64_t m_vmrss_bytes
Definition: health_monitor_process_memory_mapping.h:66
uint64_t m_page_faults
Definition: health_monitor_process_memory_mapping.h:69
bool m_details_available
Definition: health_monitor_process_memory_mapping.h:71
std::string m_name
Definition: health_monitor_process_memory_mapping.h:64
Definition: health_monitor_memory.h:37
Process memory capabilities collected at one collection point.
Definition: system_info.h:362