Add per-chain aggregate software/hardware telemetry (#464)

* Add per-chain aggregate software/hardware telemetry

* Fix tests' compilation

* Add extra comments for the `Counter` struct

* Replace the boolean argument with an enum

* Rename `replace_hwbench` to `update_hwbench`

* Move `Counter` into a separate file

* Move `ChainStatsCollator` to `chain_stats.rs`

* Fix incorrect key on the unknown table

* Improve types for the stats component; get rid of `any`
This commit is contained in:
Koute
2022-04-27 18:44:34 +09:00
committed by GitHub
parent 978c070bdd
commit 45878f9876
22 changed files with 1034 additions and 18 deletions
+13
View File
@@ -60,6 +60,7 @@ pub enum Payload {
BlockImport(Block),
NotifyFinalized(Finalized),
AfgAuthoritySet(AfgAuthoritySet),
HwBench(NodeHwBench),
}
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -93,6 +94,14 @@ pub struct AfgAuthoritySet {
pub authority_set_id: Box<str>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct NodeHwBench {
pub cpu_hashrate_score: u64,
pub memory_memcpy_score: u64,
pub disk_sequential_write_score: Option<u64>,
pub disk_random_write_score: Option<u64>,
}
impl Payload {
pub fn best_block(&self) -> Option<&Block> {
match self {
@@ -145,9 +154,13 @@ mod tests {
name: "foo".into(),
implementation: "foo".into(),
version: "foo".into(),
target_arch: Some("x86_64".into()),
target_os: Some("linux".into()),
target_env: Some("env".into()),
validator: None,
network_id: ArrayString::new(),
startup_time: None,
sysinfo: None,
},
}),
});
+34
View File
@@ -38,6 +38,40 @@ pub struct NodeDetails {
pub validator: Option<Box<str>>,
pub network_id: NetworkId,
pub startup_time: Option<Box<str>>,
pub target_os: Option<Box<str>>,
pub target_arch: Option<Box<str>>,
pub target_env: Option<Box<str>>,
pub sysinfo: Option<NodeSysInfo>,
}
/// Hardware and software information for the node.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct NodeSysInfo {
/// The exact CPU model.
pub cpu: Option<Box<str>>,
/// The total amount of memory, in bytes.
pub memory: Option<u64>,
/// The number of physical CPU cores.
pub core_count: Option<u32>,
/// The Linux kernel version.
pub linux_kernel: Option<Box<str>>,
/// The exact Linux distribution used.
pub linux_distro: Option<Box<str>>,
/// Whether the node's running under a virtual machine.
pub is_virtual_machine: Option<bool>,
}
/// Hardware benchmark results for the node.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct NodeHwBench {
/// The CPU speed, as measured in how many MB/s it can hash using the BLAKE2b-256 hash.
pub cpu_hashrate_score: u64,
/// Memory bandwidth in MB/s, calculated by measuring the throughput of `memcpy`.
pub memory_memcpy_score: u64,
/// Sequential disk write speed in MB/s.
pub disk_sequential_write_score: Option<u64>,
/// Random disk write speed in MB/s.
pub disk_random_write_score: Option<u64>,
}
/// A couple of node statistics.