mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-14 14:11:02 +00:00
Improve reported statistics (#553)
* frontend: Update package lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frontend/stats: Format linux kernel version Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * backend: Add [64; 128) RAM bucket Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * backend: Parse kernel string to include only version numbers The linux kernel version string is parsed to include only the kernel version, major version and minor version. Ignoring the patch number and kernel specific info leads to a better aggregation of data. Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * backend: Fix typo Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * core: Add CPU vendor to reported chain stats Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frontend: Propagate CPU vendor to UI Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * backend: Parse kernel version by `+` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * backend: Add CPU vendors and ignore ascii case Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "frontend/stats: Format linux kernel version" This reverts commit 411b9a4ceef9c664816404eaee1fb64f61fe85b3. * backend: Fix plus sign test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * backend: Trim kernel versions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * backend: Modify cpu_vendor Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -240,4 +240,5 @@ pub struct ChainStats {
|
||||
pub memory_memcpy_score: Ranking<(u32, Option<u32>)>,
|
||||
pub disk_sequential_write_score: Ranking<(u32, Option<u32>)>,
|
||||
pub disk_random_write_score: Ranking<(u32, Option<u32>)>,
|
||||
pub cpu_vendor: Ranking<String>,
|
||||
}
|
||||
|
||||
@@ -96,6 +96,41 @@ fn bucket_memory(memory: u64) -> (u32, Option<u32>) {
|
||||
48,
|
||||
56,
|
||||
64,
|
||||
128,
|
||||
}
|
||||
}
|
||||
|
||||
fn kernel_version_number(version: &Box<str>) -> &str {
|
||||
let index = version
|
||||
.find("-")
|
||||
.or_else(|| version.find("+"))
|
||||
.unwrap_or(version.len());
|
||||
|
||||
&version[0..index]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_kernel_version_number() {
|
||||
assert_eq!(kernel_version_number(&"5.10.0-8-amd64".into()), "5.10.0");
|
||||
// Plus sign indicates that the kernel was built from modified sources.
|
||||
// This should only appear at the end of the version string.
|
||||
assert_eq!(kernel_version_number(&"5.10.0+82453".into()), "5.10.0");
|
||||
assert_eq!(kernel_version_number(&"5.10.0".into()), "5.10.0");
|
||||
}
|
||||
|
||||
fn cpu_vendor(cpu: &Box<str>) -> &str {
|
||||
let lowercase_cpu = cpu.to_ascii_lowercase();
|
||||
|
||||
if lowercase_cpu.contains("intel") {
|
||||
"Intel"
|
||||
} else if lowercase_cpu.contains("amd") {
|
||||
"AMD"
|
||||
} else if lowercase_cpu.contains("arm") {
|
||||
"ARM"
|
||||
} else if lowercase_cpu.contains("apple") {
|
||||
"Apple"
|
||||
} else {
|
||||
"Other"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +149,7 @@ pub struct ChainStatsCollator {
|
||||
memory_memcpy_score: Counter<(u32, Option<u32>)>,
|
||||
disk_sequential_write_score: Counter<(u32, Option<u32>)>,
|
||||
disk_random_write_score: Counter<(u32, Option<u32>)>,
|
||||
cpu_vendor: Counter<String>,
|
||||
}
|
||||
|
||||
impl ChainStatsCollator {
|
||||
@@ -148,7 +184,7 @@ impl ChainStatsCollator {
|
||||
self.linux_kernel.modify(
|
||||
sysinfo
|
||||
.and_then(|sysinfo| sysinfo.linux_kernel.as_ref())
|
||||
.map(|value| &**value),
|
||||
.map(kernel_version_number),
|
||||
op,
|
||||
);
|
||||
|
||||
@@ -164,6 +200,11 @@ impl ChainStatsCollator {
|
||||
op,
|
||||
);
|
||||
|
||||
self.cpu_vendor.modify(
|
||||
sysinfo.and_then(|sysinfo| sysinfo.cpu.as_ref().map(cpu_vendor)),
|
||||
op,
|
||||
);
|
||||
|
||||
self.update_hwbench(hwbench, op);
|
||||
}
|
||||
|
||||
@@ -220,6 +261,7 @@ impl ChainStatsCollator {
|
||||
.disk_sequential_write_score
|
||||
.generate_ranking_ordered(),
|
||||
disk_random_write_score: self.disk_random_write_score.generate_ranking_ordered(),
|
||||
cpu_vendor: self.cpu_vendor.generate_ranking_top(10),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
use crate::feed_message::Ranking;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// A data structure which counts how many occurences of a given key we've seen.
|
||||
/// A data structure which counts how many occurrences of a given key we've seen.
|
||||
#[derive(Default)]
|
||||
pub struct Counter<K> {
|
||||
/// A map containing the number of occurences of a given key.
|
||||
/// A map containing the number of occurrences of a given key.
|
||||
///
|
||||
/// If there are none then the entry is removed.
|
||||
map: HashMap<K, u64>,
|
||||
|
||||
/// The number of occurences where the key is `None`.
|
||||
/// The number of occurrences where the key is `None`.
|
||||
empty: u64,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user