feat: face clustering pipeline improvements and Rust/Swift face processing
- Add Rust face processor module (detection, embedding, tracking, qdrant) - Add Facenet CoreML/ONNX conversion scripts and tests - Refactor swift_face into Sources/swift_face with ArgumentParser support - Update store_traced_faces to handle face.json correctly - Fix ASRX parsing and TKG bbox reading from Qdrant - Improve admin_config and trace_agent APIs - Add M4 workspace docs for face clustering, dedup, and Facenet validation - Fix worker heartbeat TTL (poll_interval x 3, min 60s) for offline detection
This commit is contained in:
+31
-26
@@ -23,39 +23,42 @@ struct ProcessorCleanupGuard {
|
||||
impl Drop for ProcessorCleanupGuard {
|
||||
fn drop(&mut self) {
|
||||
use tokio::sync::TryLockError;
|
||||
if let Ok(mut guard) = self.running.try_write() {
|
||||
guard.remove(&self.job_id);
|
||||
} else {
|
||||
warn!("[ProcessorCleanupGuard] running lock contended");
|
||||
|
||||
// Release running map
|
||||
match self.running.try_write() {
|
||||
Ok(mut guard) => { guard.remove(&self.job_id); }
|
||||
Err(_) => error!("[ProcessorCleanupGuard] Failed to acquire running lock for job {} - resource may leak", self.job_id),
|
||||
}
|
||||
if let Ok(mut guard) = self.running_count.try_write() {
|
||||
if *guard > 0 {
|
||||
*guard -= 1;
|
||||
}
|
||||
|
||||
// Release running count
|
||||
match self.running_count.try_write() {
|
||||
Ok(mut guard) => { if *guard > 0 { *guard -= 1; } }
|
||||
Err(_) => error!("[ProcessorCleanupGuard] Failed to release running_count for job {}", self.job_id),
|
||||
}
|
||||
if let Ok(mut guard) = self.running_per_job.try_write() {
|
||||
if let Some(c) = guard.get_mut(&self.job_id) {
|
||||
if *c > 0 {
|
||||
*c -= 1;
|
||||
}
|
||||
if *c == 0 {
|
||||
guard.remove(&self.job_id);
|
||||
|
||||
// Release per-job count
|
||||
match self.running_per_job.try_write() {
|
||||
Ok(mut guard) => {
|
||||
if let Some(c) = guard.get_mut(&self.job_id) {
|
||||
if *c > 0 { *c -= 1; }
|
||||
if *c == 0 { guard.remove(&self.job_id); }
|
||||
}
|
||||
}
|
||||
Err(_) => error!("[ProcessorCleanupGuard] Failed to release running_per_job for job {}", self.job_id),
|
||||
}
|
||||
|
||||
// Release pipeline-specific slot
|
||||
match self.pipeline {
|
||||
PipelineType::Frame => {
|
||||
if let Ok(mut guard) = self.frame_count.try_write() {
|
||||
if *guard > 0 {
|
||||
*guard -= 1;
|
||||
}
|
||||
match self.frame_count.try_write() {
|
||||
Ok(mut guard) => { if *guard > 0 { *guard -= 1; } }
|
||||
Err(_) => error!("[ProcessorCleanupGuard] Failed to release frame slot for job {}", self.job_id),
|
||||
}
|
||||
}
|
||||
PipelineType::Time => {
|
||||
if let Ok(mut guard) = self.time_count.try_write() {
|
||||
if *guard > 0 {
|
||||
*guard -= 1;
|
||||
}
|
||||
match self.time_count.try_write() {
|
||||
Ok(mut guard) => { if *guard > 0 { *guard -= 1; } }
|
||||
Err(_) => error!("[ProcessorCleanupGuard] Failed to release time slot for job {}", self.job_id),
|
||||
}
|
||||
}
|
||||
PipelineType::Cross => {}
|
||||
@@ -109,9 +112,11 @@ pub struct ProcessorTask {
|
||||
}
|
||||
|
||||
/// Frame pipeline max concurrent processors (hard limit).
|
||||
const FRAME_SLOT_MAX: usize = 2;
|
||||
/// Time pipeline max concurrent processors (audio is heavy, run 1 at a time).
|
||||
const TIME_SLOT_MAX: usize = 1;
|
||||
/// Increased from 2 to 4 to match max_concurrent and avoid resource starvation.
|
||||
const FRAME_SLOT_MAX: usize = 4;
|
||||
/// Time pipeline max concurrent processors (audio is heavy, run 2 at a time).
|
||||
/// Increased from 1 to 2 to improve throughput.
|
||||
const TIME_SLOT_MAX: usize = 2;
|
||||
|
||||
pub struct ProcessorPool {
|
||||
db: Arc<PostgresDb>,
|
||||
|
||||
Reference in New Issue
Block a user