Add FoundOrigin enum to track candidate source in engine results
This commit is contained in:
@@ -34,6 +34,15 @@ pub struct Candidate {
|
||||
pub distance: U512, // achieved distance for this nonce
|
||||
}
|
||||
|
||||
/// Origin of a found candidate.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum FoundOrigin {
|
||||
Cpu,
|
||||
GpuG1,
|
||||
GpuG2,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// Status from an engine search.
|
||||
///
|
||||
/// For synchronous `search_range` calls, the final outcome will be one of:
|
||||
@@ -50,6 +59,7 @@ pub enum EngineStatus {
|
||||
Found {
|
||||
candidate: Candidate,
|
||||
hash_count: u64,
|
||||
origin: FoundOrigin,
|
||||
},
|
||||
Exhausted {
|
||||
hash_count: u64,
|
||||
@@ -133,6 +143,7 @@ impl MinerEngine for BaselineCpuEngine {
|
||||
return EngineStatus::Found {
|
||||
candidate,
|
||||
hash_count,
|
||||
origin: FoundOrigin::Cpu,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -202,6 +213,7 @@ impl MinerEngine for FastCpuEngine {
|
||||
distance,
|
||||
},
|
||||
hash_count,
|
||||
origin: FoundOrigin::Cpu,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -324,6 +336,7 @@ impl MinerEngine for ChainManipulatorEngine {
|
||||
distance,
|
||||
},
|
||||
hash_count,
|
||||
origin: FoundOrigin::Cpu,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -384,10 +397,12 @@ mod tests {
|
||||
EngineStatus::Found {
|
||||
candidate: b_cand,
|
||||
hash_count: b_hashes,
|
||||
origin: _,
|
||||
},
|
||||
EngineStatus::Found {
|
||||
candidate: f_cand,
|
||||
hash_count: f_hashes,
|
||||
origin: _,
|
||||
},
|
||||
) => {
|
||||
assert_eq!(
|
||||
|
||||
@@ -388,6 +388,7 @@ impl CudaEngine {
|
||||
distance,
|
||||
},
|
||||
hash_count,
|
||||
origin: engine_cpu::FoundOrigin::Cpu,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -811,6 +812,7 @@ impl CudaEngine {
|
||||
distance: host_distance,
|
||||
},
|
||||
hash_count,
|
||||
origin: engine_cpu::FoundOrigin::GpuG2,
|
||||
});
|
||||
} else {
|
||||
// FP within batch — log minimal info and fall through to advance/continue
|
||||
@@ -1205,6 +1207,7 @@ impl CudaEngine {
|
||||
distance,
|
||||
},
|
||||
hash_count,
|
||||
origin: engine_cpu::FoundOrigin::GpuG1,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ impl MinerEngine for MontgomeryCpuEngine {
|
||||
distance,
|
||||
},
|
||||
hash_count,
|
||||
origin: engine_cpu::FoundOrigin::Cpu,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -818,10 +819,12 @@ mod mont_portable {
|
||||
EngineStatus::Found {
|
||||
candidate: cm,
|
||||
hash_count: hm,
|
||||
origin: _,
|
||||
},
|
||||
EngineStatus::Found {
|
||||
candidate: cf,
|
||||
hash_count: hf,
|
||||
origin: _,
|
||||
},
|
||||
) => {
|
||||
assert_eq!(cm.nonce, cf.nonce, "nonce mismatch");
|
||||
@@ -905,10 +908,12 @@ mod tests {
|
||||
EngineStatus::Found {
|
||||
candidate: m_cand,
|
||||
hash_count: m_hashes,
|
||||
origin: _,
|
||||
},
|
||||
EngineStatus::Found {
|
||||
candidate: f_cand,
|
||||
hash_count: f_hashes,
|
||||
origin: _,
|
||||
},
|
||||
) => {
|
||||
assert_eq!(
|
||||
|
||||
@@ -342,6 +342,7 @@ pub struct ThreadResult {
|
||||
thread_id: usize,
|
||||
result: Option<MiningJobResult>,
|
||||
hash_count: u64,
|
||||
origin: Option<engine_cpu::FoundOrigin>,
|
||||
completed: bool,
|
||||
}
|
||||
|
||||
@@ -554,9 +555,14 @@ impl MiningJob {
|
||||
{
|
||||
// reuse existing http metric bucket for visibility until dedicated counters exist
|
||||
metrics::inc_mine_requests("result_ready");
|
||||
// Emit per-job origin gauge with real job_id; engine reports precise origin separately
|
||||
if let Some(job_id) = &self.job_id {
|
||||
metrics::set_job_found_origin(self.engine_name, job_id, "unknown");
|
||||
let origin_label = match thread_result.origin {
|
||||
Some(engine_cpu::FoundOrigin::Cpu) => "cpu",
|
||||
Some(engine_cpu::FoundOrigin::GpuG1) => "gpu-g1",
|
||||
Some(engine_cpu::FoundOrigin::GpuG2) => "gpu-g2",
|
||||
_ => "unknown",
|
||||
};
|
||||
metrics::set_job_found_origin(self.engine_name, job_id, origin_label);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -690,6 +696,7 @@ fn mine_range_with_engine(
|
||||
distance,
|
||||
},
|
||||
hash_count,
|
||||
origin,
|
||||
} => {
|
||||
// Send final result with found candidate and the hashes covered in this subrange
|
||||
let final_result = ThreadResult {
|
||||
@@ -700,6 +707,7 @@ fn mine_range_with_engine(
|
||||
distance,
|
||||
}),
|
||||
hash_count,
|
||||
origin: Some(origin),
|
||||
completed: true,
|
||||
};
|
||||
if sender.try_send(final_result).is_err() {
|
||||
@@ -714,6 +722,7 @@ fn mine_range_with_engine(
|
||||
thread_id,
|
||||
result: None,
|
||||
hash_count,
|
||||
origin: None,
|
||||
completed: false,
|
||||
};
|
||||
if sender.try_send(update).is_err() {
|
||||
@@ -737,6 +746,7 @@ fn mine_range_with_engine(
|
||||
thread_id,
|
||||
result: None,
|
||||
hash_count,
|
||||
origin: None,
|
||||
completed: false,
|
||||
};
|
||||
if sender.try_send(update).is_err() {
|
||||
@@ -762,6 +772,7 @@ fn mine_range_with_engine(
|
||||
thread_id,
|
||||
result: None,
|
||||
hash_count: 0,
|
||||
origin: None,
|
||||
completed: true,
|
||||
};
|
||||
if sender.try_send(final_result).is_err() {
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 0,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"liveNow": false,
|
||||
"panels": [
|
||||
{
|
||||
"type": "stat",
|
||||
"title": "Total Candidates Found (gpu-cuda)",
|
||||
"description": "Total number of candidates found by the selected engine across all origins",
|
||||
"gridPos": { "h": 5, "w": 8, "x": 0, "y": 0 },
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum(miner_found_by_origin_total{engine=~\"$engine\"})"
|
||||
}
|
||||
],
|
||||
"options": {
|
||||
"reduceOptions": {
|
||||
"calcs": ["lastNotNull"],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"orientation": "auto",
|
||||
"colorMode": "value",
|
||||
"graphMode": "none",
|
||||
"justifyMode": "auto",
|
||||
"textMode": "value"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": { "unit": "none", "decimals": 0 },
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "bargauge",
|
||||
"title": "Found by Origin (Total)",
|
||||
"description": "Cumulative counts of found candidates by origin",
|
||||
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 0 },
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (origin) (miner_found_by_origin_total{engine=~\"$engine\", origin=~\"$origin\"})",
|
||||
"legendFormat": "{{origin}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": { "unit": "none", "decimals": 0 },
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"orientation": "horizontal",
|
||||
"reduceOptions": {
|
||||
"calcs": ["lastNotNull"],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Found by Origin (1m increase over time)",
|
||||
"description": "Per-origin increase in found counts (1-minute window), stacked",
|
||||
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 0 },
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (origin) (increase(miner_found_by_origin_total{engine=~\"$engine\", origin=~\"$origin\"}[1m]))",
|
||||
"legendFormat": "{{origin}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": { "unit": "none" },
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": { "displayMode": "list", "placement": "bottom", "calcs": [] },
|
||||
"tooltip": { "mode": "multi", "sort": "none" },
|
||||
"stacking": { "mode": "normal", "group": "A" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "Per-Job Found Origin (recent state)",
|
||||
"description": "Shows recent per-job origin state; a series is 1 when that origin found the job",
|
||||
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 8 },
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max_over_time(miner_job_found_origin{engine=~\"$engine\", job_id=~\"$job_id\"}[1m])",
|
||||
"legendFormat": "{{job_id}}:{{origin}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": { "unit": "none", "min": 0, "max": 1 },
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": { "displayMode": "list", "placement": "bottom" },
|
||||
"tooltip": { "mode": "multi", "sort": "none" }
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "table",
|
||||
"title": "Recent Jobs and Found Origin (last 6h)",
|
||||
"description": "Lists jobs and the origin that found them (if any) within the selected time window",
|
||||
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 16 },
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max by (engine, job_id, origin) (max_over_time(miner_job_found_origin{engine=~\"$engine\"}[6h]))",
|
||||
"legendFormat": "{{engine}}, {{job_id}}, {{origin}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": { "custom": { "align": "auto" } },
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"showHeader": true,
|
||||
"footer": { "show": false },
|
||||
"frameIndex": 0
|
||||
},
|
||||
"transformations": [
|
||||
{
|
||||
"id": "labelsToFields",
|
||||
"options": { "mode": "columns" }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "timeseries",
|
||||
"title": "GPU vs CPU Wins (1m increase over time)",
|
||||
"description": "Compare GPU (G1/G2) vs CPU parity wins over time, stacked",
|
||||
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 24 },
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (class) (label_replace(increase(miner_found_by_origin_total{engine=~\"$engine\", origin=~\"$origin\"}[1m]), \"class\", \"$1\", \"origin\", \"(gpu-g1|gpu-g2)\"))",
|
||||
"legendFormat": "gpu"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "sum by (origin) (increase(miner_found_by_origin_total{engine=~\"$engine\", origin=\"cpu\"}[1m]))",
|
||||
"legendFormat": "cpu"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": { "unit": "none" },
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": { "displayMode": "list", "placement": "bottom" },
|
||||
"tooltip": { "mode": "multi", "sort": "none" },
|
||||
"stacking": { "mode": "normal", "group": "B" }
|
||||
}
|
||||
}
|
||||
],
|
||||
"refresh": "10s",
|
||||
"schemaVersion": 38,
|
||||
"style": "dark",
|
||||
"tags": ["quantus", "miner", "prometheus", "gpu-cuda", "origins"],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "DS_PROMETHEUS",
|
||||
"hide": 0,
|
||||
"query": "prometheus",
|
||||
"current": {},
|
||||
"options": []
|
||||
},
|
||||
{
|
||||
"type": "query",
|
||||
"name": "engine",
|
||||
"label": "Engine",
|
||||
"hide": 0,
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"definition": "label_values(miner_found_by_origin_total, engine)",
|
||||
"includeAll": false,
|
||||
"multi": false,
|
||||
"refresh": 2,
|
||||
"sort": 1,
|
||||
"query": "label_values(miner_found_by_origin_total, engine)",
|
||||
"regex": "",
|
||||
"current": {
|
||||
"selected": true,
|
||||
"text": "gpu-cuda",
|
||||
"value": "gpu-cuda"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "query",
|
||||
"name": "origin",
|
||||
"label": "Origin",
|
||||
"hide": 0,
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"definition": "label_values(miner_found_by_origin_total{engine=~\"$engine\"}, origin)",
|
||||
"includeAll": true,
|
||||
"multi": true,
|
||||
"refresh": 2,
|
||||
"sort": 1,
|
||||
"query": "label_values(miner_found_by_origin_total{engine=~\"$engine\"}, origin)",
|
||||
"regex": "",
|
||||
"current": {
|
||||
"selected": false,
|
||||
"text": ["All"],
|
||||
"value": ["$__all"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "query",
|
||||
"name": "job_id",
|
||||
"label": "Job ID",
|
||||
"hide": 0,
|
||||
"datasource": "$DS_PROMETHEUS",
|
||||
"definition": "label_values(miner_job_found_origin{engine=~\"$engine\"}, job_id)",
|
||||
"includeAll": true,
|
||||
"multi": true,
|
||||
"refresh": 2,
|
||||
"sort": 1,
|
||||
"query": "label_values(miner_job_found_origin{engine=~\"$engine\"}, job_id)",
|
||||
"regex": "",
|
||||
"current": {
|
||||
"selected": false,
|
||||
"text": ["All"],
|
||||
"value": ["$__all"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": { "from": "now-6h", "to": "now" },
|
||||
"timepicker": {},
|
||||
"timezone": "",
|
||||
"title": "Quantus Miner - GPU CUDA Found Origins",
|
||||
"version": 1,
|
||||
"uid": null
|
||||
}
|
||||
Reference in New Issue
Block a user