Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da0d1582be | ||
|
|
7f802c568f |
@@ -62,6 +62,18 @@ async fn scan(cidrs: &[String]) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// Cap identification concurrency to match the GUI (see
|
||||||
|
// scan::SCAN_CONCURRENCY_LIMIT). asic-rs defaults to 1000, which over a real
|
||||||
|
// link starves the per-responder get_data -- Braiins miners drop most values
|
||||||
|
// (watts=0, no best-share) and some responders are missed entirely. 128 is the
|
||||||
|
// highest cap that stayed fully reliable on the live fleet. ALKANE_PROBE_CONCURRENCY
|
||||||
|
// overrides it for diagnostics.
|
||||||
|
let concurrency = std::env::var("ALKANE_PROBE_CONCURRENCY")
|
||||||
|
.ok()
|
||||||
|
.and_then(|c| c.parse::<usize>().ok())
|
||||||
|
.unwrap_or(128);
|
||||||
|
eprintln!("(scan concurrency = {concurrency})");
|
||||||
|
f = f.with_concurrent_limit(concurrency);
|
||||||
println!("ip\tmake\tfirmware\tfw_version\tmodel_id\tcontrol_board\twatts\tsupports_power_limit\tsupports_tuning\tbest_share\tsession_best_share");
|
println!("ip\tmake\tfirmware\tfw_version\tmodel_id\tcontrol_board\twatts\tsupports_power_limit\tsupports_tuning\tbest_share\tsession_best_share");
|
||||||
let mut stream = f.scan_stream_with_ip();
|
let mut stream = f.scan_stream_with_ip();
|
||||||
let mut found = 0usize;
|
let mut found = 0usize;
|
||||||
@@ -263,6 +275,9 @@ async fn msgs(ip_s: &str) {
|
|||||||
match f.scan_miner(ip).await {
|
match f.scan_miner(ip).await {
|
||||||
Ok(Some(m)) => {
|
Ok(Some(m)) => {
|
||||||
let d = m.get_data().await;
|
let d = m.get_data().await;
|
||||||
|
let th = |h: &Option<asic_rs::core::data::hashrate::HashRate>| {
|
||||||
|
h.clone().map(|x| x.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value)
|
||||||
|
};
|
||||||
println!(
|
println!(
|
||||||
"{ip}: {} {} hashboards={:?} expected={:?}",
|
"{ip}: {} {} hashboards={:?} expected={:?}",
|
||||||
d.device_info.firmware,
|
d.device_info.firmware,
|
||||||
@@ -270,13 +285,28 @@ async fn msgs(ip_s: &str) {
|
|||||||
d.hashboards.len(),
|
d.hashboards.len(),
|
||||||
d.expected_hashboards,
|
d.expected_hashboards,
|
||||||
);
|
);
|
||||||
|
println!(
|
||||||
|
" TOTAL hashrate={:?} TH wattage={:?} W fluid/env_temp={:?} best_share={:?}",
|
||||||
|
th(&d.hashrate),
|
||||||
|
d.wattage.as_ref().map(|p| p.as_watts()),
|
||||||
|
d.fluid_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
|
d.best_share,
|
||||||
|
);
|
||||||
|
let fans: Vec<i64> = d
|
||||||
|
.fans
|
||||||
|
.iter()
|
||||||
|
.map(|f| f.rpm.as_ref().map(|r| r.as_rpm() as i64).unwrap_or(-1))
|
||||||
|
.collect();
|
||||||
|
println!(" fans(rpm)={fans:?} psu_fans={}", d.psu_fans.len());
|
||||||
for b in d.hashboards.iter() {
|
for b in d.hashboards.iter() {
|
||||||
println!(
|
println!(
|
||||||
" board position={} hashrate={:?} chips={:?}/{:?}",
|
" board pos={} hr={:?}TH chips={:?}/{:?} board_temp={:?} outlet_temp={:?}",
|
||||||
b.position,
|
b.position,
|
||||||
b.hashrate.clone().map(|h| h.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value),
|
th(&b.hashrate),
|
||||||
b.working_chips,
|
b.working_chips,
|
||||||
b.expected_chips,
|
b.expected_chips,
|
||||||
|
b.board_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
|
b.outlet_chip_temperature.as_ref().map(|t| t.as_celsius()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if d.messages.is_empty() {
|
if d.messages.is_empty() {
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ pub const AUTO_FILE: &str = "auto-rescan-secs.txt";
|
|||||||
pub const SCAN_TIMEOUT_FILE: &str = "scan-timeout-secs.txt";
|
pub const SCAN_TIMEOUT_FILE: &str = "scan-timeout-secs.txt";
|
||||||
/// Default per-miner scan timeout (matches asic-rs' identification timeout).
|
/// Default per-miner scan timeout (matches asic-rs' identification timeout).
|
||||||
pub const DEFAULT_SCAN_TIMEOUT_SECS: u64 = 10;
|
pub const DEFAULT_SCAN_TIMEOUT_SECS: u64 = 10;
|
||||||
|
/// Maximum in-flight address probes during a scan. asic-rs would otherwise use
|
||||||
|
/// 1000 for any range up to /22, saturating a real link and starving the
|
||||||
|
/// per-responder get_data (Braiins miners drop most values under that burst).
|
||||||
|
/// 128 was the highest cap that stayed fully reliable on the live fleet.
|
||||||
|
pub const SCAN_CONCURRENCY_LIMIT: usize = 128;
|
||||||
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
||||||
/// Default seconds between automatic rescans.
|
/// Default seconds between automatic rescans.
|
||||||
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
||||||
@@ -377,7 +382,18 @@ pub fn start_scan(lines: Vec<String>, timeout_secs: u64) -> ScanHandle {
|
|||||||
};
|
};
|
||||||
rt.block_on(async move {
|
rt.block_on(async move {
|
||||||
let mut factory = crate::credentials::configured_factory()
|
let mut factory = crate::credentials::configured_factory()
|
||||||
.with_identification_timeout_secs(timeout_secs.max(1));
|
.with_identification_timeout_secs(timeout_secs.max(1))
|
||||||
|
// Cap identification concurrency. asic-rs defaults to 1000 for any
|
||||||
|
// range up to /22, so a /24 fires all 254 probes at once. Over a
|
||||||
|
// real link (VPN, or a subnet full of dead IPs whose TCP connects
|
||||||
|
// sit open for the whole identification timeout) that burst starves
|
||||||
|
// the per-responder get_data -- a Braiins miner fans out ~12
|
||||||
|
// authenticated REST calls and drops most of its values (watts=0,
|
||||||
|
// no best-share/temps), and some responders are missed entirely.
|
||||||
|
// 128 is the highest cap that stayed fully reliable on the live
|
||||||
|
// fleet (192 already dropped responders); a /24 still finishes in
|
||||||
|
// ~35s. Larger ranges just take proportionally longer, still correct.
|
||||||
|
.with_concurrent_limit(SCAN_CONCURRENCY_LIMIT);
|
||||||
for (ip, prefix) in &cidrs {
|
for (ip, prefix) in &cidrs {
|
||||||
factory = match factory.with_subnet(&format!("{ip}/{prefix}")) {
|
factory = match factory.with_subnet(&format!("{ip}/{prefix}")) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
@@ -391,7 +407,10 @@ pub fn start_scan(lines: Vec<String>, timeout_secs: u64) -> ScanHandle {
|
|||||||
// get accurate progress plus the responders.
|
// get accurate progress plus the responders.
|
||||||
let mut stream = factory.scan_stream_with_ip();
|
let mut stream = factory.scan_stream_with_ip();
|
||||||
let mut done = 0usize;
|
let mut done = 0usize;
|
||||||
let step = (total / 100).max(1); // throttle progress messages
|
// Emit progress per address for a smoothly-climbing counter; only a
|
||||||
|
// very large scan (> 5000 addresses) is throttled, to bound channel
|
||||||
|
// traffic. The UI coalesces these to one gauge update per refresh.
|
||||||
|
let step = (total / 5000).max(1);
|
||||||
while let Some((ip, miner)) = stream.next().await {
|
while let Some((ip, miner)) = stream.next().await {
|
||||||
if thread_cancel.load(Ordering::Relaxed) {
|
if thread_cancel.load(Ordering::Relaxed) {
|
||||||
return; // Stop / re-scan requested
|
return; // Stop / re-scan requested
|
||||||
|
|||||||
@@ -128,6 +128,11 @@ const ID_HDR_SORT_REL_DESC: i32 = 766;
|
|||||||
const ID_FILTER_COL: i32 = 730;
|
const ID_FILTER_COL: i32 = 730;
|
||||||
const ID_FILTER_OP: i32 = 731;
|
const ID_FILTER_OP: i32 = 731;
|
||||||
const TIMER_SCAN: i32 = 1;
|
const TIMER_SCAN: i32 = 1;
|
||||||
|
/// The scan/drain timer fires this often (ms). A fast tick drains the scan channel
|
||||||
|
/// several times a second so the progress counter climbs smoothly instead of
|
||||||
|
/// jumping ~1%/s; the once-per-second scheduler work runs every `TICKS_PER_SEC`.
|
||||||
|
const TICK_MS: i32 = 200;
|
||||||
|
const TICKS_PER_SEC: u64 = 1000 / TICK_MS as u64;
|
||||||
// Deferred-rebuild ids: run a rebuild from outside the triggering widget's own
|
// Deferred-rebuild ids: run a rebuild from outside the triggering widget's own
|
||||||
// event (destroying a control mid-event is unsafe). See `wx_rs::call_after`.
|
// event (destroying a control mid-event is unsafe). See `wx_rs::call_after`.
|
||||||
const DEFER_TABLE: i32 = 1;
|
const DEFER_TABLE: i32 = 1;
|
||||||
@@ -640,6 +645,9 @@ pub struct App {
|
|||||||
// Per-miner scan timeout in seconds (round 14 #2).
|
// Per-miner scan timeout in seconds (round 14 #2).
|
||||||
scan_timeout_secs: u64,
|
scan_timeout_secs: u64,
|
||||||
countdown: u64,
|
countdown: u64,
|
||||||
|
/// Counts fast timer ticks; the once-per-second scheduler runs every
|
||||||
|
/// `TICKS_PER_SEC` of these (the drains run every tick for smooth progress).
|
||||||
|
tick_accum: u64,
|
||||||
// selection (replaces the old checkbox column), tracked by IP so it
|
// selection (replaces the old checkbox column), tracked by IP so it
|
||||||
// survives table refreshes during a scan.
|
// survives table refreshes during a scan.
|
||||||
selected_ips: HashSet<String>,
|
selected_ips: HashSet<String>,
|
||||||
@@ -983,6 +991,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
auto_secs: scan::load_auto_secs(),
|
auto_secs: scan::load_auto_secs(),
|
||||||
scan_timeout_secs: scan::load_scan_timeout(),
|
scan_timeout_secs: scan::load_scan_timeout(),
|
||||||
countdown: 0,
|
countdown: 0,
|
||||||
|
tick_accum: 0,
|
||||||
selected_ips: HashSet::new(),
|
selected_ips: HashSet::new(),
|
||||||
pal,
|
pal,
|
||||||
kpi_cards,
|
kpi_cards,
|
||||||
@@ -1057,7 +1066,7 @@ pub fn build(frame: Widget) -> App {
|
|||||||
app.view = p.view.to_view();
|
app.view = p.view.to_view();
|
||||||
}
|
}
|
||||||
app.rebuild_table();
|
app.rebuild_table();
|
||||||
Widget::timer(TIMER_SCAN, 1000);
|
Widget::timer(TIMER_SCAN, TICK_MS);
|
||||||
app
|
app
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2620,6 +2629,9 @@ impl App {
|
|||||||
pub fn drain_scan(&mut self) {
|
pub fn drain_scan(&mut self) {
|
||||||
let Some(handle) = &self.scan else { return };
|
let Some(handle) = &self.scan else { return };
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
// Coalesce progress: a fast drain may pull many per-address updates; apply
|
||||||
|
// only the latest to the gauge/status once, after the loop.
|
||||||
|
let mut latest_progress: Option<(usize, usize, String)> = None;
|
||||||
loop {
|
loop {
|
||||||
match handle.rx.try_recv() {
|
match handle.rx.try_recv() {
|
||||||
Ok(ScanMsg::Started { total, targets }) => {
|
Ok(ScanMsg::Started { total, targets }) => {
|
||||||
@@ -2643,12 +2655,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
Ok(ScanMsg::Progress { done, total, ip }) => {
|
Ok(ScanMsg::Progress { done, total, ip }) => {
|
||||||
self.scan_total = total;
|
self.scan_total = total;
|
||||||
self.progress.gauge_set_value(done.min(total) as i32);
|
latest_progress = Some((done, total, ip));
|
||||||
let where_ = if ip.is_empty() { String::new() } else { format!(" - scanning {ip}") };
|
|
||||||
wx_rs::set_status_text(&format!(
|
|
||||||
"{done}/{total}{where_} ({} found)",
|
|
||||||
self.rows.len()
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
Ok(ScanMsg::Row(row)) => {
|
Ok(ScanMsg::Row(row)) => {
|
||||||
// Ignore stray rows outside the current target set.
|
// Ignore stray rows outside the current target set.
|
||||||
@@ -2692,6 +2699,15 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Apply the coalesced progress once (only while still scanning -- a Done/
|
||||||
|
// Failed in this same drain already finalised the gauge).
|
||||||
|
if self.scanning {
|
||||||
|
if let Some((done, total, ip)) = latest_progress {
|
||||||
|
self.progress.gauge_set_value(done.min(total) as i32);
|
||||||
|
let where_ = if ip.is_empty() { String::new() } else { format!(" - scanning {ip}") };
|
||||||
|
wx_rs::set_status_text(&format!("{done}/{total}{where_} ({} found)", self.rows.len()));
|
||||||
|
}
|
||||||
|
}
|
||||||
if changed {
|
if changed {
|
||||||
self.fill_rows();
|
self.fill_rows();
|
||||||
}
|
}
|
||||||
@@ -2705,6 +2721,13 @@ impl App {
|
|||||||
self.drain_refresh();
|
self.drain_refresh();
|
||||||
self.drain_access_probe();
|
self.drain_access_probe();
|
||||||
self.drain_restore();
|
self.drain_restore();
|
||||||
|
// The drains above run every fast tick (smooth scan progress); the
|
||||||
|
// auto-rescan scheduler + idle status only need ~1 Hz, so run them once
|
||||||
|
// per second.
|
||||||
|
self.tick_accum = self.tick_accum.wrapping_add(1);
|
||||||
|
if self.tick_accum % TICKS_PER_SEC != 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// The bottom-left status is for the scan only (round 15 #8): per-miner
|
// The bottom-left status is for the scan only (round 15 #8): per-miner
|
||||||
// operation progress lives in the Health column, so operations no longer
|
// operation progress lives in the Health column, so operations no longer
|
||||||
// hold or overwrite this line -- only an active scan does.
|
// hold or overwrite this line -- only an active scan does.
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
Subject: [PATCH 0016] braiins v26_04: single-flight auth + defensive get_data timeout
|
||||||
|
|
||||||
|
Round 17 R4 support. Braiins get_data fans out to ~12 authenticated REST calls
|
||||||
|
concurrently. Two hardening changes so a Braiins miner survives a busy scan:
|
||||||
|
|
||||||
|
- ensure_authenticated single-flights the login. Previously all ~12 concurrent
|
||||||
|
commands could see no token and each POST /auth/login -- a thundering herd that
|
||||||
|
doubled the connection load. Now the write lock is held across the login with a
|
||||||
|
double-check, so exactly one call authenticates and the rest reuse the token.
|
||||||
|
- The per-call timeout goes 5s -> 15s as defensive headroom (a healthy miner still
|
||||||
|
answers well under a second) so a call queued behind a scan burst completes
|
||||||
|
instead of dropping miner/stats.
|
||||||
|
|
||||||
|
Neither is the primary fix for the fleet-scan value dropout -- that is the
|
||||||
|
app-side scan concurrency cap (scan::SCAN_CONCURRENCY_LIMIT = 128), which keeps
|
||||||
|
the identification burst from starving these calls. These are the belt to that
|
||||||
|
suspenders. Verified live: a 10.4.1.0/24 scan now populates both Braiins corpus
|
||||||
|
miners (.27, .83) fully (watts, best-share, fw/control-board) and misses no
|
||||||
|
responders.
|
||||||
|
diff --git a/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs b/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
index 3e06b682..ae433d98 100644
|
||||||
|
--- a/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
+++ b/vendor/asic-rs-firmwares-braiins/src/backends/v26_04/web.rs
|
||||||
|
@@ -87,7 +87,13 @@ impl BraiinsWebAPI {
|
||||||
|
client: OnceCell::new(),
|
||||||
|
ip,
|
||||||
|
port: 80,
|
||||||
|
- timeout: Duration::from_secs(5),
|
||||||
|
+ // Braiins get_data fans out to ~12 authenticated REST calls that run
|
||||||
|
+ // concurrently. A healthy miner answers well under a second; the extra
|
||||||
|
+ // headroom over the old 5 s is defensive so a call that queues behind a
|
||||||
|
+ // scan burst still completes instead of dropping miner/stats
|
||||||
|
+ // (hashrate/watts/best-share). The real fix for the fleet-scan dropout
|
||||||
|
+ // is the app-side scan concurrency cap (see scan::SCAN_CONCURRENCY_LIMIT).
|
||||||
|
+ timeout: Duration::from_secs(15),
|
||||||
|
bearer_token: RwLock::new(None),
|
||||||
|
auth,
|
||||||
|
}
|
||||||
|
@@ -122,13 +128,22 @@ impl BraiinsWebAPI {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Single-flight the login: get_data fires ~12 commands concurrently, and
|
||||||
|
+ // without this they would ALL see no token and each POST /auth/login (a
|
||||||
|
+ // thundering herd that doubles the connection load and races under a
|
||||||
|
+ // high-concurrency fleet scan, dropping most values). Hold the write lock
|
||||||
|
+ // across the login so exactly one call authenticates and the rest reuse it.
|
||||||
|
+ let mut guard = self.bearer_token.write().await;
|
||||||
|
+ if guard.is_some() {
|
||||||
|
+ return Ok(());
|
||||||
|
+ }
|
||||||
|
let token = match &self.auth {
|
||||||
|
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
||||||
|
MinerAuth::UserAndPass(creds) => {
|
||||||
|
self.authenticate(creds.password.expose_secret()).await?
|
||||||
|
}
|
||||||
|
};
|
||||||
|
- *self.bearer_token.write().await = Some(token);
|
||||||
|
+ *guard = Some(token);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
+17
-2
@@ -87,7 +87,13 @@ impl BraiinsWebAPI {
|
|||||||
client: OnceCell::new(),
|
client: OnceCell::new(),
|
||||||
ip,
|
ip,
|
||||||
port: 80,
|
port: 80,
|
||||||
timeout: Duration::from_secs(5),
|
// Braiins get_data fans out to ~12 authenticated REST calls that run
|
||||||
|
// concurrently. A healthy miner answers well under a second; the extra
|
||||||
|
// headroom over the old 5 s is defensive so a call that queues behind a
|
||||||
|
// scan burst still completes instead of dropping miner/stats
|
||||||
|
// (hashrate/watts/best-share). The real fix for the fleet-scan dropout
|
||||||
|
// is the app-side scan concurrency cap (see scan::SCAN_CONCURRENCY_LIMIT).
|
||||||
|
timeout: Duration::from_secs(15),
|
||||||
bearer_token: RwLock::new(None),
|
bearer_token: RwLock::new(None),
|
||||||
auth,
|
auth,
|
||||||
}
|
}
|
||||||
@@ -122,13 +128,22 @@ impl BraiinsWebAPI {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Single-flight the login: get_data fires ~12 commands concurrently, and
|
||||||
|
// without this they would ALL see no token and each POST /auth/login (a
|
||||||
|
// thundering herd that doubles the connection load and races under a
|
||||||
|
// high-concurrency fleet scan, dropping most values). Hold the write lock
|
||||||
|
// across the login so exactly one call authenticates and the rest reuse it.
|
||||||
|
let mut guard = self.bearer_token.write().await;
|
||||||
|
if guard.is_some() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
let token = match &self.auth {
|
let token = match &self.auth {
|
||||||
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
MinerAuth::TokenAuth(token) => token.expose_secret().to_string(),
|
||||||
MinerAuth::UserAndPass(creds) => {
|
MinerAuth::UserAndPass(creds) => {
|
||||||
self.authenticate(creds.password.expose_secret()).await?
|
self.authenticate(creds.password.expose_secret()).await?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*self.bearer_token.write().await = Some(token);
|
*guard = Some(token);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user