Skip to content

Commit c2663f2

Browse files
BengangYgangj
authored andcommitted
CP-53858: Domain CPU ready RRD1 metric - runnable_any
Adding a new metric 'runnable_any' as % of time that at least one vCPU of the domain is in the runnable state. It is the sum of the following 3 metrics: - runstate_full_contention - runstate_concurrency_hazard - runstate_partial_contention Naming it 'runnable_any' instead of 'runnable' is to resolve one problem with rrd2csv: if we name it 'runnable', rrd2csv will select both RRD1("runnable") and RRD2("runnable_vcpus") when the 'runnable' is used: > rrd2csv AVERAGE:vm:<vm-uuid>:runnable > timestamp, AVERAGE:vm:<vm-uuid>:runnable, AVERAGE:vm:<vm-uuid>:runnable_vcpus This is because "runnable" is a prefix of "runnable_vcpus". Naming it 'runnable_any', with rrd2csv: * can select only RRD1 if we use: rrd2csv AVERAGE:vm:<vm-uuid>:runnable_any * can select only RRD2 if we use: rrd2csv AVERAGE:vm:<vm-uuid>:runnable_vcpus * can select both RRD1 and RRD2 if we use: rrd2csv AVERAGE:vm:<vm-uuid>:runnable Naming it 'runnable_any' also makes it clearer as the 'runnable' metric is % of time that at least one vCPU of the domain is in the runnable state. Add max to "runnable_any" metric to follow the fix here: #6493 Signed-off-by: Bengang Yuan <[email protected]> [Rebase with renaming and one fix] Signed-off-by: Gang Ji <[email protected]>
1 parent 809bad5 commit c2663f2

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Process = Rrdd_plugin.Process (struct let name = "xcp-rrdd-cpu" end)
2020

2121
let xen_flag_complement = Int64.(shift_left 1L 63 |> lognot)
2222

23-
(* This function is used for getting vcpu stats of the VMs present on this host. *)
23+
(* This function is used for getting vCPU stats of the VMs present on this host. *)
2424
let dss_vcpus xc doms =
2525
List.fold_left
2626
(fun dss (dom, uuid, domid) ->
@@ -49,27 +49,28 @@ let dss_vcpus xc doms =
4949
in
5050
cpus (i + 1) (cputime_rrd :: dss)
5151
in
52-
(* Runstate info is per-domain rather than per-vcpu *)
52+
(* Runstate info is per-domain rather than per-vCPU *)
5353
let dss =
5454
let dom_cpu_time =
5555
Int64.(to_float @@ logand dom.Xenctrl.cpu_time xen_flag_complement)
5656
in
5757
let dom_cpu_time =
5858
dom_cpu_time /. (1.0e9 *. float_of_int dom.Xenctrl.nr_online_vcpus)
5959
in
60+
let ( ++ ) = Int64.add in
6061
try
6162
let ri = Xenctrl.domain_get_runstate_info xc domid in
6263
( Rrd.VM uuid
6364
, Ds.ds_make ~name:"runstate_fullrun" ~units:"(fraction)"
6465
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time0 /. 1.0e9))
65-
~description:"Fraction of time that all VCPUs are running"
66+
~description:"Fraction of time that all vCPUs are running"
6667
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
6768
)
6869
:: ( Rrd.VM uuid
6970
, Ds.ds_make ~name:"runstate_full_contention" ~units:"(fraction)"
7071
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time1 /. 1.0e9))
7172
~description:
72-
"Fraction of time that all VCPUs are runnable (i.e., \
73+
"Fraction of time that all vCPUs are runnable (i.e., \
7374
waiting for CPU)"
7475
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
7576
)
@@ -78,22 +79,22 @@ let dss_vcpus xc doms =
7879
~units:"(fraction)"
7980
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time2 /. 1.0e9))
8081
~description:
81-
"Fraction of time that some VCPUs are running and some are \
82+
"Fraction of time that some vCPUs are running and some are \
8283
runnable"
8384
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
8485
)
8586
:: ( Rrd.VM uuid
8687
, Ds.ds_make ~name:"runstate_blocked" ~units:"(fraction)"
8788
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time3 /. 1.0e9))
8889
~description:
89-
"Fraction of time that all VCPUs are blocked or offline"
90+
"Fraction of time that all vCPUs are blocked or offline"
9091
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
9192
)
9293
:: ( Rrd.VM uuid
9394
, Ds.ds_make ~name:"runstate_partial_run" ~units:"(fraction)"
9495
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time4 /. 1.0e9))
9596
~description:
96-
"Fraction of time that some VCPUs are running, and some are \
97+
"Fraction of time that some vCPUs are running and some are \
9798
blocked"
9899
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
99100
)
@@ -102,10 +103,27 @@ let dss_vcpus xc doms =
102103
~units:"(fraction)"
103104
~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time5 /. 1.0e9))
104105
~description:
105-
"Fraction of time that some VCPUs are runnable and some are \
106+
"Fraction of time that some vCPUs are runnable and some are \
106107
blocked"
107108
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
108109
)
110+
:: ( Rrd.VM uuid
111+
, Ds.ds_make ~name:"runnable_any" ~units:"(fraction)"
112+
~value:
113+
(Rrd.VT_Float
114+
(Int64.to_float
115+
(ri.Xenctrl.time1
116+
++ ri.Xenctrl.time2
117+
++ ri.Xenctrl.time5
118+
)
119+
/. 1.0e9
120+
)
121+
)
122+
~description:
123+
"Fraction of time that at least one vCPU is runnable in the \
124+
domain"
125+
~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 ()
126+
)
109127
:: ( Rrd.VM uuid
110128
, Ds.ds_make
111129
~name:(Printf.sprintf "cpu_usage")

0 commit comments

Comments
 (0)