MySQL 9.4.0
Source Code Documentation
my_system.h
Go to the documentation of this file.
1/* Copyright (c) 2025 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#pragma once
25
26#include <cstdint>
27
28using ulonglong = unsigned long long;
29
30/**
31 Initialize the my_physical_memory function using server_memory option
32 @param[in] memory Value of the server_memory startup option
33
34 @note The input value of 0 indicates no limits, and underlying container/host
35 configuration must be used
36 @return true on success, false if input memory value is invalid
37*/
39
40/**
41 Determine the total physical memory available in bytes.
42
43 If process is running within a container, then memory available is the maximum
44 limit set for the container. If the process is not running in a container then
45 it uses the appropriate system APIs to determine the available memory.
46
47 If the API is unable to determine the available memory, then it returns 0.
48
49 @return physical memory in bytes or 0
50*/
51uint64_t my_physical_memory() noexcept;
52
53/**
54 Determine the total number of logical CPUs available.
55
56 If process is running within a container, the number of logical CPUs is the
57 maximum limit set for the container. If the process is not running in a
58 container then it uses the appropriate system APIs to determine the number of
59 logical CPUs.
60
61 If the API is unable to determine the number of logical CPUs, then it returns
62 0.
63
64 @note: The container set limits are calculated from the CFS quota and period
65 as quota/period and is round down. A limit of 0.5 will return the value 0 and
66 is treated as though no limits are set.
67
68 @return number of logical CPUs or 0
69*/
70uint32_t my_num_vcpus() noexcept;
unsigned long long int ulonglong
Definition: my_inttypes.h:56
uint32_t my_num_vcpus() noexcept
Determine the total number of logical CPUs available.
Definition: my_system.cc:110
uint64_t my_physical_memory() noexcept
Determine the total physical memory available in bytes.
Definition: my_system.cc:103
bool init_my_physical_memory(ulonglong memory)
Initialize the my_physical_memory function using server_memory option.
Definition: my_system.cc:90
Definition: aligned_atomic.h:44