Skip to content

feat(recorder): coalesce active recording disk inspection and cache live stats - #3

Open
Kimlimp wants to merge 1 commit into
bilipp:mainfrom
Kimlimp:perf/recorder-live-stats
Open

Kimlimp wants to merge 1 commit into
bilipp:mainfrom
Kimlimp:perf/recorder-live-stats

Conversation

@Kimlimp

@Kimlimp Kimlimp commented Nov 6, 2026

Copy link
Copy Markdown

Summary

Implements Issue 6 (Recorder statistics) from the performance evaluation roadmap:

  • Adds LiveStatsCoordinator actor to coalesce concurrent disk inspection of active recordings into a single in-flight scan.
  • Introduces configurable freshness TTL caching (liveStatsFreshness, default 2.0s) to eliminate repeated directory scans for active recordings across rapid poll loops.
  • Offloads blocking MediaInspector.stats disk I/O onto a dedicated concurrent DispatchQueue (com.lume.recorder.live-stats-io), preventing Hummingbird HTTP request threads and cooperative Swift concurrency worker pools from stalling.
  • Integrates invalidation across the recording lifecycle: segment append notifications, retry attempts, stop requests, deletions, and finalization.
  • Handles race conditions where media directory is deleted while an inspection is in-flight.
  • Preserves exact persisted statistics for finished recordings (completed, failed, etc.) without performing redundant live disk scans.

Verification

  • Added LiveStatsTests test suite covering:
    • 20 concurrent list polls coalescing into a single disk scan.
    • Zero redundant disk scans for repeated polls within the freshness interval.
    • Finished recordings using cached store stats without disk reads.
    • Lifecycle invalidation upon append, retry, stop, and finalization.
    • In-flight inspection racing deletion.
    • Benchmark with 2,500 segments confirming unrelated requests (/api/v1/info) respond in 1 ms without stalling behind cold disk inspection.
  • Entire test suite passes cleanly (68 tests in 10 suites).

…ive stats

- Add LiveStatsCoordinator actor with single-flight coalescing and configurable freshness TTL (default 2.0s)
- Offload blocking FileManager stats to a dedicated I/O executor so Hummingbird / cooperative threads stay responsive
- Invalidate and clean up live cache on retry, stop, delete, and finalization
- Ensure finished recordings continue to use exact cached stats from store without live disk inspection
- Add full test coverage in LiveStatsTests verifying concurrent poll coalescing, TTL caching, lifecycle invalidation, racing deletion, and thousands-of-segments benchmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant