perf: let the measured typed/lane cost decide for failure-heavy typed groups

This commit is contained in:
Stefan Miljakovic
2026-10-10 08:56:12 +02:00
parent a577adbc2a
commit 1132829506
2 changed files with 1 additions and 17 deletions
-4
View File
@@ -921,14 +921,10 @@ impl<'a> Run<'_, 'a> {
}
let path = op.cost.path();
let start = Instant::now();
let failed = self.store.failed;
let typed = match path.0 {
Path::Typed => self.lowered(seg, op, positions).map(|lowered| self.merged(seg, op, units, positions, lowered)).is_some(),
Path::Lane => false,
};
if typed {
op.cost.failing(self.store.failed.saturating_sub(failed), local);
}
if !typed {
self.laned(seg, units, positions);
}
+1 -13
View File
@@ -4,7 +4,7 @@ use crate::compiled::lowered::Exports;
use crate::compiled::shred::Seen;
use crate::compiled::table::Table;
use crate::compiled::{Body, CompiledGraph, Kind};
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering};
use std::sync::atomic::{AtomicU32, AtomicU64, Ordering};
use std::sync::{Arc, RwLock};
use std::time::Duration;
use zen_expression::lane::{Binding as Site, Fusion};
@@ -67,7 +67,6 @@ pub(crate) struct Cost {
calls: AtomicU32,
typed: AtomicU64,
lane: AtomicU64,
heavy: AtomicBool,
}
struct Probe<'p> {
@@ -136,18 +135,11 @@ impl Cost {
calls: AtomicU32::new(0),
typed: AtomicU64::new(u64::MAX),
lane: AtomicU64::new(u64::MAX),
heavy: AtomicBool::new(false),
}
}
pub fn path(&self) -> (Path, bool) {
let call = self.calls.fetch_add(1, Ordering::Relaxed);
if self.heavy.load(Ordering::Relaxed) {
return match call % Self::PERIOD {
0 => (Path::Typed, true),
_ => (Path::Lane, false),
};
}
if call < Self::WARM {
return (Path::Typed, false);
}
@@ -165,10 +157,6 @@ impl Cost {
}
}
pub fn failing(&self, failed: usize, rows: usize) {
self.heavy.store(failed * 4 > rows, Ordering::Relaxed);
}
pub fn record(&self, (path, fresh): (Path, bool), elapsed: Duration, rows: usize) {
let per = u64::try_from(elapsed.as_nanos().saturating_mul(1024) / rows.max(1) as u128).unwrap_or(u64::MAX - 1);
let cell = match path {