Flow-IPC 3.0.0
Flow-IPC project: Full implementation reference.
stat_info_dump.hpp
Go to the documentation of this file.
1/* Flow-IPC: SHM-jemalloc
2 * Copyright (c) 2023 Akamai Technologies, Inc.; and other contributors.
3 * Each commit is copyright by its respective author or author's employer.
4 *
5 * Licensed under the MIT License:
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE. */
24
25/// @file
26#pragma once
27
30#include "ipc/util/util.hpp"
31#include <string>
32#include <vector>
33
35{
36
37// Types.
38
39/**
40 * Printable (with knobs in contained util::stat::Info_dump_format) bundling of stats/info relevant to (but not
41 * all necessarily owned by) a particular jemalloc::Ipc_arena as stat-consumed at a particular point in time.
42 * - Stats/info stored by-value; can be queried in peace.
43 * - Can be printed to an `ostream` via `ostream<<`. #m_fmt (`Info_dump_format`) has output-format knobs,
44 * adjusting which ahead of the `<<` will affect the output.
45 * - As usual: can `FLOW_LOG_...(x)` it, `boost::lexical_cast<string>(x)` it, `flow::util::ostream_op_string(x)`,
46 * where `x` is a `*this`.
47 *
48 * ### Subject matter ###
49 * One fills-out the payload by calling `arena.info_dump(&x)`, where `arena` is an `Ipc_arena`; `x` is a `*this`.
50 *
51 * Some of the items saved in a `*this` were (pre-copying-them-into-`*this`) owned by/pertaining to the
52 * specific target Ipc_arena `arena`. (E.g.: #m_sharded_stats.)
53 *
54 * Others (e.g.: #m_owner_pool_lookup_global_stats) are global -- not pertaining to any particular arena -- but
55 * pertain to SHM-arena(s) in general, at least tangentially. Such entities are a/k/a *owner-side*. So they
56 * pertain to `Ipc_arena`s in at least some sense... just not necessarily to *the* arena `arena` that filled `*this`.
57 *
58 * The non-per-`Ipc_arena` data in `*this` may be redundant w/r/t the non-per-`Ipc_arena` data in `*that`.
59 * It is still included simply out of the pragmatic belief that, if one is interested about "everything"
60 * about arena X, they'll want to know about data/algorithms that make arena X (...but also other arenas)
61 * work properly. I.e.: the more the merrier.
62 *
63 * @see The other, disjoint such bundling in SHM-jemalloc is Shm_session_info_dump
64 * (<=> session::shm::arena_lend::jemalloc::Shm_session); it is generally *borrower-side* info.
65 * (Arena_info_dump (<=> jemalloc::Ipc_arena) is SHM-jemalloc's *owner-side* info.)
66 */
68{
69 // Data.
70
71 /**
72 * Print-format knobs in effect at `ostream << *this` time.
73 *
74 * @note Info_dump_format::m_verbose specifically controls whether -- if available in the first
75 * place -- #m_mem_mgr_stats_dump (as from jemalloc::Memory_manager::stats_dump_to_ostream())
76 * shall be included in the output (`true` <=> yes). Additionally if `false` at Ipc_arena::info_dump()
77 * call, then #m_mem_mgr_stats_dump is not generated (empty string saved). However:
78 * @note Info_dump_format::m_multiline being `false` shall cause printing as-if `m_verbose == false`
79 * regardless of its actual value. (It is not reasonable to print jemalloc's huge #m_mem_mgr_stats_dump,
80 * if newlines are not allowed.) `m_multiline` does not affect `info_dump()` generating/saving or not
81 * generating/saving the dump (only `m_verbose` is consulted for that).
82 */
84
85 /// If unavailable then empty; otherwise the newline-terminated output of Memory_manager::stats_dump_to_ostream().
87
88 /// Target `Ipc_arena`'s stats from: Ipc_arena::memory_manager_stats().
89 std::vector<arena_lend::stat::Memory_manager_stats> m_mem_mgr_stats;
90
91 /// Target `Ipc_arena`'s stats from: Ipc_arena::sharded_stats().
93
94 /// Target `Ipc_arena`'s stats from: Ipc_arena::pool_stats().
96
97 /// Global stats from: `static` Ipc_arena::obj_db_aux_pool_global_stats().
99
100 /// Global stats from: `static` Ipc_arena::owner_pool_lookup_global_stats().
102
103 /// Target `Ipc_arena`'s info from: Ipc_arena::shm_pool_live_info().
104 std::vector<arena_lend::stat::Shm_pool_info> m_shm_pool_live_info;
105}; // struct Arena_info_dump
106
107/**
108 * Printable (with knobs in contained util::stat::Info_dump_format) bundling of stats/info relevant to (but not
109 * all necessarily owned by) a particular session::shm::arena_lend::jemalloc::Shm_session as stat-consumed at
110 * particular point in time.
111 *
112 * @see brief notes in a similar place in Arena_info_dump doc header.
113 *
114 * ### Subject matter ###
115 * One fills-out the payload by calling `sess.info_dump(&x)`, where `sess` is a `Shm_session`; `x` is a `*this`.
116 *
117 * Some of the items saved in a `*this` were (pre-copying-them-into-`*this`) owned by/pertaining to the
118 * specific target `Shm_session sess`. (E.g.: #m_borrower_pool_stats.)
119 *
120 * Others (e.g.: #m_borrower_pool_lookup_global_stats) are global -- not pertaining to any particular session -- but
121 * pertain to SHM-session(s) in general, at least tangentially. Such entities are a/k/a *borrower-side*. So they
122 * pertain to `Shm_session`s in at least some sense... just not necessarily to *the* session `sess` that filled `*this`.
123 *
124 * As with Arena_info_dump + Ipc_arena: the preceding paragraph means 2 `Shm_session_info_dump`s will, in the
125 * global-style members, have potentially mutually-redundant -- but still of potential interest -- information.
126 *
127 * @see The other, disjoint such bundling in SHM-jemalloc is Arena_info_dump (<=> jemalloc::Ipc_arena);
128 * it is generally *owner-side* info. (Shm_session_info_dump (<=> session::shm::arena_lend::jemalloc::Shm_session)
129 * is SHM-jemalloc's *borrower-side* info.)
130 */
132{
133 // Data.
134
135 /**
136 * Print-format knobs in effect at `ostream << *this` time.
137 *
138 * @note Info_dump_format::m_verbose specifically controls whether #m_borrower_pool_stats_process_wide_per_arena
139 * gathers/prints all (potentially hundreds) past borrowed arenas' stuff; if `false` then only up to
140 * ~tens (as of this writing) are saved, and if any were thus omitted this is
141 * saved/printed in #m_borrower_pool_stats_process_wide_per_arena_n_omitted.
142 */
144
145 /// Target `Shm_session`'s stats from: `Shm_session::borrower_pool_stats()`.
147
148 /// Global stats from: `static Shm_session::borrower_pool_stats_process_wide()`: return value.
150
151 /// Global stats from: `static Shm_session::borrower_pool_stats_process_wide()`: the per-arena out-arg.
152 std::vector<arena_lend::stat::Borrower_pool_stats> m_borrower_pool_stats_process_wide_per_arena;
153
154 /**
155 * If `m_fmt.m_verbose == false` at `Shm_session::info_dump()` time, this is the # (possibly zero) of entries excluded
156 * from #m_borrower_pool_stats_process_wide_per_arena to keep it small; otherwise zero (as then none is omitted).
157 */
159
160 /// Global stats from: `static Shm_session::borrower_pool_lookup_global_stats()`.
162
163 /// Global info from: `static Shm_session::shm_pool_live_info()`.
164 std::vector<arena_lend::stat::Shm_pool_info> m_borrowed_shm_pool_live_info;
165}; // struct Shm_session_info_dump
166
167} // namespace ipc::shm::arena_lend::jemalloc::stat
Stats-related sub-namespace for SHM-jemalloc, for general organization (and ADL segregation if needed...
Printable (with knobs in contained util::stat::Info_dump_format) bundling of stats/info relevant to (...
std::vector< arena_lend::stat::Shm_pool_info > m_shm_pool_live_info
Target Ipc_arena's info from: Ipc_arena::shm_pool_live_info().
arena_lend::stat::Obj_db_aux_pool_global_stats m_obj_db_aux_pool_global_stats
Global stats from: static Ipc_arena::obj_db_aux_pool_global_stats().
util::stat::Info_dump_format m_fmt
Print-format knobs in effect at ostream << *this time.
arena_lend::stat::Owner_pool_lookup_global_stats m_owner_pool_lookup_global_stats
Global stats from: static Ipc_arena::owner_pool_lookup_global_stats().
std::vector< arena_lend::stat::Memory_manager_stats > m_mem_mgr_stats
Target Ipc_arena's stats from: Ipc_arena::memory_manager_stats().
arena_lend::stat::Sharded_stats m_sharded_stats
Target Ipc_arena's stats from: Ipc_arena::sharded_stats().
std::string m_mem_mgr_stats_dump
If unavailable then empty; otherwise the newline-terminated output of Memory_manager::stats_dump_to_o...
arena_lend::stat::Pool_stats m_pool_stats
Target Ipc_arena's stats from: Ipc_arena::pool_stats().
Printable (with knobs in contained util::stat::Info_dump_format) bundling of stats/info relevant to (...
size_t m_borrower_pool_stats_process_wide_per_arena_n_omitted
If m_fmt.m_verbose == false at Shm_session::info_dump() time, this is the # (possibly zero) of entrie...
arena_lend::stat::Borrower_pool_stats m_borrower_pool_stats_process_wide_total
Global stats from: static Shm_session::borrower_pool_stats_process_wide(): return value.
arena_lend::stat::Borrower_pool_stats m_borrower_pool_stats
Target Shm_session's stats from: Shm_session::borrower_pool_stats().
std::vector< arena_lend::stat::Borrower_pool_stats > m_borrower_pool_stats_process_wide_per_arena
Global stats from: static Shm_session::borrower_pool_stats_process_wide(): the per-arena out-arg.
util::stat::Info_dump_format m_fmt
Print-format knobs in effect at ostream << *this time.
std::vector< arena_lend::stat::Shm_pool_info > m_borrowed_shm_pool_live_info
Global info from: static Shm_session::shm_pool_live_info().
arena_lend::stat::Borrower_pool_lookup_global_stats m_borrower_pool_lookup_global_stats
Global stats from: static Shm_session::borrower_pool_lookup_global_stats().
Analogous subject matter to Owner_pool_lookup_global_stats but borrower-side.
Loosely similar subject matter to Owner_pool_stats but regarding the borrower-side view of SHM-pools,...
Similar mission to Obj_db_aux_pool_stats but covers information that, by nature, is not per-arena but...
Similar mission to Owner_pool_stats but covers information that, by nature, is not per-arena but rath...
Bundles together per-arena Owner_pool_stats and Obj_db_aux_pool_stats, so they can be accessed via on...
A bundle of several individually-documented stat-sets – object construct/dispose/live and zombie-reap...
Knobs meant to control the cosmetics of printing (ostream <<) a bundling of stats/info for some parti...
Definition: util.hpp:39