libxtc
0.4.0
Async concurrency for C: Tokio + Seastar + BEAM, in one library
Loading...
Searching...
No Matches
xtc_runtime.h
1
/*-
2
* Copyright (c) 2026, The XTC Project
3
* Use of this source code is governed by the ISC License.
4
*
5
* src/inc/xtc_runtime.h
6
* Process-level runtime introspection -- one call that reports
7
* what this process was given: how many event loops it runs, the
8
* CPU topology it sees, and any configured memory budget. Where
9
* xtc_inspect.h (xtc_inspect_loops / xtc_inspect_procs) gives the
10
* live per-loop / per-proc detail, this is the single aggregate a
11
* libxtc application reads once at startup to size itself to the
12
* box: buffer-pool bytes, worker counts, morsel granularity.
13
*
14
* The aim is that an application never has to reach into the
15
* internal __os_* topology surface (os_cpu.h) or stitch together
16
* xtc_exec_n_loops + xtc_app_exec by hand; xtc_runtime_info()
17
* collects it all into one struct.
18
*/
19
20
#ifndef XTC_RUNTIME_H
21
#define XTC_RUNTIME_H
22
23
#include <stdint.h>
24
25
#include "xtc.h"
26
27
/*
28
* A one-shot snapshot of the process runtime environment.
29
*
30
* The CPU and NUMA fields are queried from the OS at call time
31
* (they do not change over the life of the process on any supported
32
* platform). n_loops reflects the executor the CALLER is running on
33
* (see below). The memory fields report a configured cap and the
34
* bytes currently charged against it, if such accounting is in force.
35
*/
36
typedef
struct
xtc_runtime_info {
37
int
n_loops;
/* event loops in the running app/exec, or 1 standalone */
38
int
n_cpus_online;
/* __os_ncpus() */
39
int
n_cpus_perf;
/* __os_ncpus_perf() -- performance cores */
40
int
n_cpus_effic;
/* __os_ncpus_effic() -- efficiency cores */
41
int
numa_nodes;
/* __os_numa_nnodes() */
42
int64_t mem_cap_bytes;
/* configured memory cap, or 0 if none/unknown */
43
int64_t mem_used_bytes;
/* currently accounted memory in use, or 0 */
44
}
xtc_runtime_info_t
;
45
46
/*
47
* PUBLIC: int xtc_runtime_info __P((xtc_runtime_info_t *));
48
*/
49
50
/*
51
* Fill *out with a snapshot of the runtime environment. Returns
52
* XTC_OK on success, or XTC_E_INVAL if `out` is NULL.
53
*
54
* Field semantics:
55
*
56
* n_loops
57
* The number of event loops in the executor the CALLER runs on.
58
* When called from a fiber/task on a loop owned by a multi-loop
59
* executor (xtc_exec / a multi-loop xtc_app), this is that
60
* executor's loop count. On a standalone loop it is 1. When
61
* called from a thread that is NOT on any loop (e.g. before the
62
* executor starts, or from a plain helper thread), there is no
63
* thread-local "current executor" to consult, so it defaults to
64
* 1. LIMITATION: libxtc keeps no process-global registry of the
65
* current app/exec, only a thread-local current-loop; to read the
66
* true loop count from off-loop, hold the exec handle and call
67
* xtc_exec_n_loops(xtc_app_exec(app)) directly.
68
*
69
* n_cpus_online / n_cpus_perf / n_cpus_effic / numa_nodes
70
* The OS-reported CPU topology (online logical CPUs, performance
71
* cores, efficiency cores, NUMA nodes). On platforms or
72
* hardware without a perf/effic split, all online CPUs count as
73
* performance cores and n_cpus_effic is 0. numa_nodes is at
74
* least 1.
75
*
76
* mem_cap_bytes / mem_used_bytes
77
* A configured memory budget and the bytes charged against it.
78
* LIMITATION: libxtc's memory accounting (xtc_res, XTC_RES_MEM_BYTES)
79
* is an opt-in, caller-owned facility -- there is no process-global
80
* or default resource accountant reachable from here, and these
81
* fields are NOT the OS-reported RSS. Both are therefore reported
82
* as 0 ("no cap / unknown"); an application that wants its own
83
* quota reflected should read its xtc_res_t directly with
84
* xtc_res_used(r, XTC_RES_MEM_BYTES) against r->caps.mem_bytes.
85
*/
86
int
xtc_runtime_info(
xtc_runtime_info_t
*out);
87
88
#endif
/* XTC_RUNTIME_H */
xtc_runtime_info_t
Definition
xtc_runtime.h:36
src
inc
xtc_runtime.h
Generated by
1.9.8