Files
RedBear-OS/local
kellito 045aaa4579 v5.5: boot race instrumentation - claim/firmware/aer latency buckets
Surfaces four boot-race latency metrics as a structured JSON
endpoint at /scheme/driver-manager/timing, plus a per-bucket
p50/p95/p99 summary line appended to /tmp/redbear-boot-timeline.json.

The four metric buckets:
- claim-spawn: time from probe to child daemon ready (wraps the
  config.rs::probe() spawn path).
- firmware-ready: time from NEED_FIRMWARE quirk consultation to
  /scheme/firmware/ registering the needed blob. Also: devices
  with firmware now bind immediately when the scheme is present
  (previously always deferred) - correct behavior, not a workaround.
- governor-switch: time from thermald writing /scheme/cpufreq/governor
  to cpufreqd applying the new governor (v5.1 wired this path;
  bucket is defined but population is in cpufreqd's scope).
- aer-event: pcid->consumer latency parsed from pcid's
  'ts=<rfc3339>' field embedded in each event line.

Architecture:
- timing.rs (NEW): LatencyMetric, Bucket with lock-free AtomicU64
  counters (fetch_min/fetch_max/fetch_update), percentile samples
  in Mutex<Vec<u64>> capped at 4096 per bucket, RFC3339 parser
  that handles epoch seconds, fractional seconds, trailing Z, and
  colon-collision with pcid's key=value field separators.
- config.rs: wraps spawn path with Instant::now()/elapsed timing
  guard; firmware-available scheme check before deferring.
- unified_events.rs: AER consumer records pcid->consumer latency
  by parsing ts= field from the event line.
- scheme.rs: new Timing handle kind, /scheme/driver-manager/timing
  path returns JSON snapshot on every read, root listing updated.
- main.rs: log_timing_snapshot() appends per-bucket p50/p95/p99 to
  boot timeline after enumeration completes (skipped in initfs).

Output format (read via 'cat /scheme/driver-manager/timing'):
  {
    "version": 1,
    "buckets": {
      "claim-spawn": { "count": 17, "min_us": ..., ... },
      "firmware-ready": { ... },
      "governor-switch": { ... },
      "aer-event": { ... }
    }
  }

Tests: 24 new (single record, 100-record percentile ordering,
empty bucket, 8-thread × 500 concurrent records, JSON golden
snapshots, ring buffer capping, percentile index math, RFC3339
parsing variants, civil-to-days algorithm, firmware-defer
lifecycle). Total 112 tests pass, 0 failed.

Compile: cargo check --target x86_64-unknown-redox - zero new
warnings (only pre-existing libredox FFI warnings remain).

Constraints per local/AGENTS.md:
- No new branches (work on 0.3.1)
- No new Cargo dependencies (std-only: AtomicU64, Mutex, Vec, etc.)
- No stubs, no todo!/unimplemented!
- Cat 1 in-house recipe - source IS the durable location

Closes v5.5 of the v5.x work program.
2026-07-26 00:20:48 +09:00
..