MySQL 26.7.0
Source Code Documentation
statistics_map.h
Go to the documentation of this file.
1// Copyright (c) 2026, 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#ifndef MYSQL_SCHEDULER_STATISTICS_MAP_H
25#define MYSQL_SCHEDULER_STATISTICS_MAP_H
26
27#include <atomic>
28#include <thread>
29#include <unordered_map>
31
32namespace mysql::scheduler {
33
34/// Supported statistics:
35/// * thp_queue_size - current size of the thread pool queue size
36/// * thp_task_exec_time - the number of microseconds spent by workers to
37/// execute tasks
38/// * thp_worker_exec_time - the number of microseconds spent to by thread pool
39/// workers on waiting for tasks and execute tasks
40/// * sched_task_exec_time - the number of microseconds spent by workers to
41/// execute tasks, without callback overhead
42/// * thp_thread_internal_id - thread internal id, set once after thread starts
44 public:
45 static constexpr auto thp_queue_size = "thp_queue_size";
46 static constexpr auto thp_task_exec_time = "thp_task_exec_time";
47 static constexpr auto thp_worker_exec_time = "thp_worker_exec_time";
48 static constexpr auto sched_task_exec_time = "sched_task_exec_time";
49 static constexpr auto thp_thread_internal_id = "thp_thread_internal_id";
50 [[nodiscard]] static bool init_statistics(
51 std::size_t instance_id,
52 std::size_t num_threads = Constants::max_thread_count,
53 bool enable_extended_statistics = false);
54};
55
56} // namespace mysql::scheduler
57
58#endif // MYSQL_SCHEDULER_STATISTICS_MAP_H
Supported statistics:
Definition: statistics_map.h:43
static bool init_statistics(std::size_t instance_id, std::size_t num_threads=Constants::max_thread_count, bool enable_extended_statistics=false)
Definition: statistics_map.cpp:32
static constexpr auto thp_thread_internal_id
Definition: statistics_map.h:49
static constexpr auto thp_queue_size
Definition: statistics_map.h:45
static constexpr auto thp_worker_exec_time
Definition: statistics_map.h:47
static constexpr auto thp_task_exec_time
Definition: statistics_map.h:46
static constexpr auto sched_task_exec_time
Definition: statistics_map.h:48
Definition: base_dependency_tracker.h:41
static constexpr unsigned int max_thread_count
The maximum number of threads in the thread pool This value should be aligned with the MTS_MAX_WORKER...
Definition: constants.h:38