Remove in-place flag, optimize presence counting, and handle NUMA panics
The `obikmer select` CLI no longer supports in-place index rewriting; the `--output` flag is now required, with benchmarks updated to use temporary directories for atomic replacement. Added `--dense` and `--force-copy` flags. Introduced `batch_presence_counts` to compute presence counts across multiple column groups in a single pass, eliminating redundant I/O. Refactored the aggregation pipeline to branch on layer content, applying the optimized batched counting for `Presence` layers. Enhanced the NUMA runner to catch worker panics, track them, and re-raise after thread join to prevent indefinite blocking.
This commit is contained in:
1 parent
7363370065
commit
93fe838f97
9 files changed
+330
-26
No files matched your search
@@ -1,3 +1,5 @@
|
||||
use std::any::Any;
|
||||
use std::panic::{self, AssertUnwindSafe};
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@@ -164,6 +166,7 @@ impl PartitionRunner {
|
||||
let f = &f;
|
||||
|
||||
let mut first_err: Option<E> = None;
|
||||
let mut first_panic: Option<Box<dyn Any + Send + 'static>> = None;
|
||||
|
||||
std::thread::scope(|s| {
|
||||
// ── Timer thread ──────────────────────────────────────────────────
|
||||
@@ -208,12 +211,27 @@ impl PartitionRunner {
|
||||
for i in &prx {
|
||||
debug!(?tid, partition = i, "PartitionRunner worker: picked partition");
|
||||
let t = Instant::now();
|
||||
let r = match &pool {
|
||||
// Caught, not left to unwind straight through this
|
||||
// spawned thread: a panicking `f(i)` would
|
||||
// otherwise never reach `etx.send(...)` below, so
|
||||
// the controller's `completed < n_total` loop
|
||||
// waits forever for an event this partition can
|
||||
// no longer produce (see `run`'s own docs on the
|
||||
// termination protocol) — silently hanging
|
||||
// instead of surfacing the panic. Caught here and
|
||||
// re-raised on the caller's thread once `run`
|
||||
// returns, so the original message/backtrace
|
||||
// still surfaces, just from the right place.
|
||||
let outcome = panic::catch_unwind(AssertUnwindSafe(|| match &pool {
|
||||
Some(p) => p.install(|| f(i)),
|
||||
None => f(i),
|
||||
};
|
||||
}));
|
||||
debug!(?tid, partition = i, "PartitionRunner worker: partition done");
|
||||
etx.send(WorkerEvent::Completed(i, r, t.elapsed())).ok();
|
||||
let event = match outcome {
|
||||
Ok(r) => WorkerEvent::Completed(i, r, t.elapsed()),
|
||||
Err(payload) => WorkerEvent::Panicked(i, payload),
|
||||
};
|
||||
etx.send(event).ok();
|
||||
}
|
||||
debug!(?tid, "PartitionRunner worker: no more partitions, exiting");
|
||||
});
|
||||
@@ -260,6 +278,21 @@ impl PartitionRunner {
|
||||
n_total,
|
||||
);
|
||||
}
|
||||
WorkerEvent::Panicked(_i, payload) => {
|
||||
// Counts toward `completed` like any other outcome —
|
||||
// this partition will never produce a `Completed`
|
||||
// event, so not counting it here is exactly what
|
||||
// used to hang the controller forever. The payload
|
||||
// is re-raised on the caller's thread once `run`
|
||||
// returns (see below), not here: unwinding out of
|
||||
// this `recv` loop would leak the still-running
|
||||
// worker/timer threads this `thread::scope` owns.
|
||||
if first_panic.is_none() {
|
||||
first_panic = Some(payload);
|
||||
}
|
||||
completed += 1;
|
||||
reset_tx.send(()).ok();
|
||||
}
|
||||
WorkerEvent::TimerTick => {
|
||||
maybe_activate(
|
||||
&mut activation,
|
||||
@@ -279,6 +312,15 @@ impl PartitionRunner {
|
||||
drop(reset_tx);
|
||||
});
|
||||
|
||||
// A panic takes priority over a plain `Err`: it means `f` itself hit
|
||||
// a bug (an unhandled case, an assertion) rather than a normal,
|
||||
// typed failure — worth surfacing with its original message/
|
||||
// backtrace via unwinding, not silently downgraded to whatever `Err`
|
||||
// another, unrelated partition happened to return first.
|
||||
if let Some(payload) = first_panic {
|
||||
panic::resume_unwind(payload);
|
||||
}
|
||||
|
||||
match first_err {
|
||||
Some(e) => Err(e),
|
||||
None => Ok(()),
|
||||
@@ -290,6 +332,11 @@ impl PartitionRunner {
|
||||
|
||||
enum WorkerEvent<R, E> {
|
||||
Completed(usize, Result<R, E>, Duration),
|
||||
/// `f(i)` panicked instead of returning — see `run`'s own docs on why
|
||||
/// this is caught at all (never letting the panic unwind straight
|
||||
/// through the spawned worker thread) rather than a bug fix that could
|
||||
/// be skipped.
|
||||
Panicked(usize, Box<dyn Any + Send + 'static>),
|
||||
TimerTick,
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user