frontend/src-tauri/LOGGING_OPTIMIZATIONS.md
This document outlines the comprehensive logging optimizations implemented to eliminate transcription delays caused by excessive output/logging overhead.
Files Modified: audio/pipeline.rs, whisper_engine/whisper_engine.rs
Before:
debug!("Pipeline received chunk {} with {} samples")log::info!("Final transcription result: '{}'", result)After:
Impact: Eliminates I/O blocking in audio processing hot paths
Files Modified: lib.rs, audio/pipeline.rs, whisper_engine/whisper_engine.rs
Implementation:
// Performance-optimized macros that compile to nothing in release builds
#[cfg(debug_assertions)]
macro_rules! perf_debug {
($($arg:tt)*) => { log::debug!($($arg)*) };
}
#[cfg(not(debug_assertions))]
macro_rules! perf_debug {
($($arg:tt)*) => {}; // No-op in release builds
}
Impact: Zero logging overhead in production builds
Files Created: audio/async_logger.rs
Features:
Impact: Eliminates I/O blocking by moving logging to background thread
Files Created: audio/batch_processor.rs
Features:
Impact: Replaces frequent individual logs with periodic summaries
Files Modified: audio/recording_manager.rs
Changes:
Impact: Reduces recording operation logging spam
Files Modified: analytics/analytics.rs, audio/hardware_detector.rs
Changes:
eprintln! with log::warn! in analyticsprintln! to log::debug!Impact: Consistent structured logging, no uncontrolled output
| Component | Before | After | Reduction |
|---|---|---|---|
| Audio Pipeline | Every chunk | Every 100 chunks | 99% |
| Transcription Results | Every result | Every 5th result | 80% |
| VAD Processing | Every detection | Debug level only | 90% |
| Error Messages | Every error | Every 100th error | 99% |
| Segment Processing | Every segment | Disabled | 100% |
perf_debug! macros active for debuggingperf_debug! macros compile to no-opsuse crate::{perf_debug, perf_trace};
// Use performance-optimized macros in hot paths
perf_debug!("Processing chunk {}", chunk_id); // Zero cost in release
// Use async logging for non-critical info
async_info!("Status update: {}", status); // Non-blocking
// Always use standard logging for errors (don't optimize away)
log::error!("Critical error: {}", error);
// Use batched logging for frequent warnings
if error_count % 100 == 1 {
log::warn!("Frequent warning (showing every 100th): {}", warning);
}
The optimizations were validated through:
These comprehensive logging optimizations eliminate transcription delays by:
The result is a highly optimized audio transcription system with minimal logging overhead that maintains debuggability in development while achieving maximum performance in production.