P0: Fix clippy warnings and remove broken openraft dep for clean CI

- Add Default impls for TaskStateMachine and RaftTaskRegistry (clippy::new_without_default)
- Remove openraft dep that fails on stable Rust 1.87 (validit uses let_chains)
- Silence dead_code warnings in raft_proto benchmark module
- Add autobenches = false to miroir-core Cargo.toml
- Update Cargo.lock

All Phase 0 DoD criteria pass: build, test (73), clippy, fmt, musl release.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
jedarden 2026-04-18 23:38:24 -04:00
parent c30d867d27
commit 21aebb386c
5 changed files with 52 additions and 672 deletions

686
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@ version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
autobenches = false
[dependencies]
serde = { version = "1", features = ["derive"] }
@ -18,13 +19,13 @@ config = "0.14"
# Raft prototype (P12.OP2 research) — not for production use
# openraft 0.9.22 fails on stable Rust 1.87 (validit uses let_chains).
# The prototype simulates Raft; only bincode is needed for serialization benchmarks.
openraft = { version = "0.9", features = ["serde"], optional = true }
bincode = { version = "2", features = ["serde"], optional = true }
[features]
raft-proto = ["bincode"]
# Enable when openraft compiles on stable Rust:
# raft-full = ["openraft", "bincode"]
# (openraft dep removed from manifest — restore when upstream fixes let_chains on stable)
[[bin]]
name = "bench-reshard-load"

View file

@ -9,11 +9,12 @@
use super::command::TaskStoreCommand;
use super::state_machine::TaskStateMachine;
use crate::task::{MiroirTask, NodeTask, NodeTaskStatus, TaskFilter, TaskStatus};
use crate::task::{MiroirTask, NodeTask, NodeTaskStatus, TaskStatus};
use std::collections::HashMap;
use std::time::Instant;
/// Simulates Redis-style direct HashMap access (no serialization, no consensus).
#[allow(dead_code)]
struct DirectStore {
tasks: HashMap<String, MiroirTask>,
}
@ -67,6 +68,7 @@ impl DirectStore {
}
#[derive(Debug)]
#[allow(dead_code)]
struct BenchResult {
name: String,
insert_ns: f64,
@ -74,6 +76,7 @@ struct BenchResult {
update_ns: f64,
}
#[allow(dead_code)]
fn bench_state_machine(n: usize) -> BenchResult {
let mut sm = TaskStateMachine::new();
let mut insert_latencies = Vec::with_capacity(n);
@ -121,6 +124,7 @@ fn bench_state_machine(n: usize) -> BenchResult {
}
}
#[allow(dead_code)]
fn bench_direct_store(n: usize) -> BenchResult {
let mut store = DirectStore::new();
let mut insert_latencies = Vec::with_capacity(n);
@ -159,6 +163,7 @@ fn bench_direct_store(n: usize) -> BenchResult {
}
}
#[allow(dead_code)]
fn bench_serialization(n: usize) -> (f64, f64, usize, usize) {
let cmd = TaskStoreCommand::InsertTask {
node_tasks: vec![

View file

@ -27,20 +27,12 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;
/// Simulated Raft consensus overhead.
///
/// In a real Raft cluster, every write goes through:
/// 1. Serialize command → log entry
/// 2. Send to majority of peers (network RTT)
/// 3. Each peer persists to disk (fsync)
/// 4. Majority ACK → leader commits
/// 5. Apply to state machine
///
/// The network + fsync dominates. This constant represents the consensus overhead
/// based on published openraft benchmarks and typical K8s pod-to-pod latency.
/// Simulated Raft consensus overhead — used by benchmark tests only.
#[allow(dead_code)]
const RAFT_CONSENSUS_OVERHEAD: Duration = Duration::from_micros(2500); // 2.5ms median
/// Redis network overhead (same cluster, pod-to-pod).
/// Redis network overhead — used by benchmark tests only.
#[allow(dead_code)]
const REDIS_NETWORK_OVERHEAD: Duration = Duration::from_micros(500); // 0.5ms median
/// Raft-backed implementation of TaskRegistry.
@ -58,6 +50,12 @@ pub struct RaftTaskRegistry {
state_machine: Arc<std::sync::Mutex<TaskStateMachine>>,
}
impl Default for RaftTaskRegistry {
fn default() -> Self {
Self::new()
}
}
impl RaftTaskRegistry {
pub fn new() -> Self {
Self {

View file

@ -48,6 +48,12 @@ pub struct TaskStateMachine {
last_applied_log_index: u64,
}
impl Default for TaskStateMachine {
fn default() -> Self {
Self::new()
}
}
impl TaskStateMachine {
pub fn new() -> Self {
Self {