Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

perf(diagnostics): keep stop-path tracing out of Release

altic-deva5d32e6a2d5f
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index e557f9cf..9cf47994 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -4919,7 +4919,7 @@ extension ContentView {
startMethod: AnalyticsOnboardingTryoutStartMethod = .hotkey
) {
DebugLogger.shared.debug("Begin dictation recording for slot \(slot.rawValue)", source: "ContentView")
- DebugLogger.shared.info("CLOSE_DETAIL nextStartRequested uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")
+ DebugLogger.shared.debug("CLOSE_DETAIL nextStartRequested uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")
self.appBench("begin_recording slot=\(slot.rawValue) mode=\(mode.rawValue)")
if self.isOnboardingVoicePlaygroundStepActive {
self.asr.finalText = ""
diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swift
index 489a9d44..840aa20a 100644
--- a/Sources/Fluid/Services/ASRService.swift
+++ b/Sources/Fluid/Services/ASRService.swift
@@ -1511,7 +1511,7 @@ final class ASRService: ObservableObject {
reason: reason,
recoveringRoute: self.isRecoveringAudioRoute
)
- DebugLogger.shared.info("CLOSE_DETAIL audioCallerResumed uptime=\(ProcessInfo.processInfo.systemUptime) awaitMs=\((ProcessInfo.processInfo.systemUptime - captureAwaitStartedAt) * 1000)", source: "StopTiming")
+ DebugLogger.shared.debug("CLOSE_DETAIL audioCallerResumed uptime=\(ProcessInfo.processInfo.systemUptime) awaitMs=\((ProcessInfo.processInfo.systemUptime - captureAwaitStartedAt) * 1000)", source: "StopTiming")
if report.status != noErr {
DebugLogger.shared.warning(
"Direct Core Audio stop returned OSStatus \(report.status)",
@@ -1531,7 +1531,7 @@ final class ASRService: ObservableObject {
if let engine = self.engineStorage as? AVAudioEngine, engine.isRunning {
engine.stop()
}
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"STOP_TRACE backend=audioEngine removeTapMs=\(Int((tapStopFinishedAt - tapStopStartedAt) * 1000)) engineStopMs=\(Int((ProcessInfo.processInfo.systemUptime - tapStopFinishedAt) * 1000))",
source: "StopTiming"
)
@@ -2841,7 +2841,7 @@ final class ASRService: ObservableObject {
var tracePreviousAt = traceStartedAt
func traceStop(_ phase: String) {
let now = ProcessInfo.processInfo.systemUptime
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"STOP_TRACE phase=\(phase) deltaMs=\(Int((now - tracePreviousAt) * 1000)) totalMs=\(Int((now - traceStartedAt) * 1000))",
source: "StopTiming"
)
diff --git a/Sources/Fluid/Services/DirectCoreAudioInput.swift b/Sources/Fluid/Services/DirectCoreAudioInput.swift
index fdf53949..fbd1b3c5 100644
--- a/Sources/Fluid/Services/DirectCoreAudioInput.swift
+++ b/Sources/Fluid/Services/DirectCoreAudioInput.swift
@@ -503,7 +503,7 @@ private final nonisolated class DirectCoreAudioInput: DirectCoreAudioInputContro
let hardwareStoppedAt = ProcessInfo.processInfo.systemUptime
fv_core_audio_capture_wake(capture)
self.workerGroup.wait()
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"STOP_TRACE backend=direct hardwareStopMs=\(Int((hardwareStoppedAt - stopStartedAt) * 1000)) workerDrainMs=\(Int((ProcessInfo.processInfo.systemUptime - hardwareStoppedAt) * 1000))",
source: "StopTiming"
)
@@ -1167,7 +1167,7 @@ final nonisolated class DirectCoreAudioLifecycleController: @unchecked Sendable
level: .info
)
trace.mark("postStopState")
- DebugLogger.shared.info("CLOSE_DETAIL audioContinuationResume uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")
+ DebugLogger.shared.debug("CLOSE_DETAIL audioContinuationResume uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")
return StopReport(
status: status,
droppedPackets: droppedPackets,
diff --git a/Sources/Fluid/Services/GlobalHotkeyManager.swift b/Sources/Fluid/Services/GlobalHotkeyManager.swift
index b0a4754a..1ccd4145 100644
--- a/Sources/Fluid/Services/GlobalHotkeyManager.swift
+++ b/Sources/Fluid/Services/GlobalHotkeyManager.swift
@@ -2348,7 +2348,7 @@ final class GlobalHotkeyManager: NSObject {
return false
}
guard !self.isProcessingStop else {
- DebugLogger.shared.info("CLOSE_DETAIL shortcutRejected stopLocked=true uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")
+ DebugLogger.shared.debug("CLOSE_DETAIL shortcutRejected stopLocked=true uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")
return false
}
guard !self.asrService.isDictionaryTrainingCaptureActive else {
@@ -2542,6 +2542,6 @@ private extension GlobalHotkeyManager {
func traceStopUnlocked(since startedAt: TimeInterval) {
self.isProcessingStop = false
- DebugLogger.shared.info("CLOSE_DETAIL shortcutUnlocked uptime=\(ProcessInfo.processInfo.systemUptime) heldMs=\((ProcessInfo.processInfo.systemUptime - startedAt) * 1000)", source: "StopTiming")
+ DebugLogger.shared.debug("CLOSE_DETAIL shortcutUnlocked uptime=\(ProcessInfo.processInfo.systemUptime) heldMs=\((ProcessInfo.processInfo.systemUptime - startedAt) * 1000)", source: "StopTiming")
}
}
diff --git a/Sources/Fluid/Services/MenuBarManager.swift b/Sources/Fluid/Services/MenuBarManager.swift
index 8e80fb92..a3653bf2 100644
--- a/Sources/Fluid/Services/MenuBarManager.swift
+++ b/Sources/Fluid/Services/MenuBarManager.swift
@@ -133,7 +133,7 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {
if isRunning {
self.hasDeferredStoppedRecordingState = false
OverlayAudioLevelState.shared.isLive = true
- DebugLogger.shared.info("WAVEFORM_LIVE", source: "StopTiming")
+ DebugLogger.shared.debug("WAVEFORM_LIVE", source: "StopTiming")
}
self.isRecording = isRunning
self.updateMenuBarIcon()
@@ -497,18 +497,18 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {
MainActor.assumeIsolated {
let refreshStartedAt = ProcessInfo.processInfo.systemUptime
self?.flushDeferredStoppedRecordingState()
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"HIDE_NOW postCommitMenuRefreshUs=\(Int((ProcessInfo.processInfo.systemUptime - refreshStartedAt) * 1_000_000))",
source: "StopTiming"
)
}
}
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"HIDE_NOW windowHideUs=\(Int((windowHideReturnedAt - startedAt) * 1_000_000)) " +
"menuRefreshUs=\(Int((ProcessInfo.processInfo.systemUptime - windowHideReturnedAt) * 1_000_000))",
source: "StopTiming"
)
- DebugLogger.shared.info("STOP_TRACE phase=hide_dispatched closingAnimation=\(SettingsStore.shared.overlayClosingAnimationEnabled) elapsedMs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1000))", source: "StopTiming")
+ DebugLogger.shared.debug("STOP_TRACE phase=hide_dispatched closingAnimation=\(SettingsStore.shared.overlayClosingAnimationEnabled) elapsedMs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1000))", source: "StopTiming")
self.overlayBench(
"finish_hide_dispatched elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))"
)
@@ -523,15 +523,15 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {
}
let startedAt = ProcessInfo.processInfo.systemUptime
self.prepareForProcessingCompletion()
- DebugLogger.shared.info("HIDE_TRACE phase=completion_prepared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")
+ DebugLogger.shared.debug("HIDE_TRACE phase=completion_prepared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")
NotchOverlayManager.shared.setProcessing(false)
- DebugLogger.shared.info("HIDE_TRACE phase=processing_cleared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")
+ DebugLogger.shared.debug("HIDE_TRACE phase=processing_cleared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")
self.overlayBench("finish_hide_request mode=awaited")
let hideOutcome = await NotchOverlayManager.shared.hideAndWait()
let hiddenAt = ProcessInfo.processInfo.systemUptime
self.flushDeferredStoppedRecordingState()
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"STOP_TRACE phase=overlay_hidden hideMs=\(Int((hiddenAt - startedAt) * 1000)) menuRefreshMs=\(Int((ProcessInfo.processInfo.systemUptime - hiddenAt) * 1000))",
source: "StopTiming"
)
diff --git a/Sources/Fluid/Services/NotchOverlayManager.swift b/Sources/Fluid/Services/NotchOverlayManager.swift
index 326ab168..d1c6c2ae 100644
--- a/Sources/Fluid/Services/NotchOverlayManager.swift
+++ b/Sources/Fluid/Services/NotchOverlayManager.swift
@@ -417,12 +417,12 @@ final class NotchOverlayManager {
// Stop monitoring active app changes
ActiveAppMonitor.shared.stopMonitoring()
- DebugLogger.shared.info("HIDE_TRACE phase=monitor_stopped elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")
+ DebugLogger.shared.debug("HIDE_TRACE phase=monitor_stopped elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")
// Hide bottom overlay if visible
if self.isBottomOverlayVisible {
let bottomOutcome = await BottomOverlayWindowController.shared.hideAndWait()
- DebugLogger.shared.info("HIDE_TRACE phase=bottom_returned elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")
+ DebugLogger.shared.debug("HIDE_TRACE phase=bottom_returned elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")
guard bottomOutcome == .hidden else {
Self.overlayBench("hide_return reason=bottom_superseded")
return .superseded
diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swift
index f93c6f9a..a859f672 100644
--- a/Sources/Fluid/Views/BottomOverlayView.swift
+++ b/Sources/Fluid/Views/BottomOverlayView.swift
@@ -149,7 +149,7 @@ final class BottomOverlayWindowController {
}
self.window?.alphaValue = 1
CATransaction.setCompletionBlock {
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"SHOW_COMMIT elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))",
source: "StopTiming"
)
@@ -184,7 +184,7 @@ final class BottomOverlayWindowController {
self.activeHideGeneration = currentGeneration
let visualStartedAt = ProcessInfo.processInfo.systemUptime
self.beginDismissalVisualIfPresented(generation: currentGeneration)
- DebugLogger.shared.info("HIDE_TRACE phase=dismissal_state elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - visualStartedAt) * 1_000_000))", source: "StopTiming")
+ DebugLogger.shared.debug("HIDE_TRACE phase=dismissal_state elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - visualStartedAt) * 1_000_000))", source: "StopTiming")
Task { [weak self] in
guard let self else { return }
let outcome = await self.performHideAndWait(generation: currentGeneration)
@@ -209,7 +209,7 @@ final class BottomOverlayWindowController {
MainActor.assumeIsolated {
guard let self, self.presentationGeneration == generation else { return }
self.window?.alphaValue = 0
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"EXIT_DONE elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))",
source: "StopTiming"
)
@@ -276,7 +276,7 @@ final class BottomOverlayWindowController {
// ignoresMouseEvents fence can never delay the visual removal.
CATransaction.setCompletionBlock { [weak self] in
MainActor.assumeIsolated {
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"HIDE_COMMIT elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))",
source: "StopTiming"
)
@@ -288,7 +288,7 @@ final class BottomOverlayWindowController {
self.scheduleIgnoreMouseEventsAfterHide()
}
}
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"HIDE_NOW hideUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000)) " +
"windowVisible=\(self.window?.isVisible == true)",
source: "StopTiming"
@@ -309,7 +309,7 @@ final class BottomOverlayWindowController {
guard let self, self.window?.alphaValue == 0 else { return }
let startedAt = ProcessInfo.processInfo.systemUptime
self.window?.ignoresMouseEvents = true
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"HIDE_NOW deferredIgnoreMouseUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))",
source: "StopTiming"
)
@@ -355,7 +355,7 @@ final class BottomOverlayWindowController {
self.activeHideGeneration = currentGeneration
let visualStartedAt = ProcessInfo.processInfo.systemUptime
self.beginDismissalVisualIfPresented(generation: currentGeneration)
- DebugLogger.shared.info("HIDE_TRACE phase=awaited_dismissal_state elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - visualStartedAt) * 1_000_000))", source: "StopTiming")
+ DebugLogger.shared.debug("HIDE_TRACE phase=awaited_dismissal_state elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - visualStartedAt) * 1_000_000))", source: "StopTiming")
let outcome = await self.performHideAndWait(generation: currentGeneration)
self.completeHideOperation(generation: currentGeneration, outcome: outcome)
return outcome
@@ -385,7 +385,7 @@ final class BottomOverlayWindowController {
var previousTraceTime = startedAt
func traceHide(_ phase: String) {
let now = ProcessInfo.processInfo.systemUptime
- DebugLogger.shared.info("HIDE_TRACE phase=\(phase) deltaUs=\(Int((now - previousTraceTime) * 1_000_000)) totalUs=\(Int((now - startedAt) * 1_000_000))", source: "StopTiming")
+ DebugLogger.shared.debug("HIDE_TRACE phase=\(phase) deltaUs=\(Int((now - previousTraceTime) * 1_000_000)) totalUs=\(Int((now - startedAt) * 1_000_000))", source: "StopTiming")
previousTraceTime = now
}
Self.overlayBench("bottom_hide_start windowExists=\(self.window != nil)")
@@ -761,7 +761,7 @@ final class BottomOverlayWindowController {
)
let originStartedAt = ProcessInfo.processInfo.systemUptime
window.setFrameOrigin(edge)
- DebugLogger.shared.info(
+ DebugLogger.shared.debug(
"HIDE_TRACE phase=parking_detail accessibilityUs=\(Int((accessibilityClearedAt - parkingStartedAt) * 1_000_000)) " +
"geometryUs=\(Int((originStartedAt - accessibilityClearedAt) * 1_000_000)) " +
"setOriginUs=\(Int((ProcessInfo.processInfo.systemUptime - originStartedAt) * 1_000_000))",
diff --git a/Sources/Fluid/Views/OverlayCloseDiagnostics.swift b/Sources/Fluid/Views/OverlayCloseDiagnostics.swift
index f88efb0f..d563b2f8 100644
--- a/Sources/Fluid/Views/OverlayCloseDiagnostics.swift
+++ b/Sources/Fluid/Views/OverlayCloseDiagnostics.swift
@@ -18,9 +18,10 @@ struct OverlayCloseTrace {
}
mutating func finish() {
+ guard DebugLogger.diagnosticsEnabled else { return }
let total = (ProcessInfo.processInfo.systemUptime - self.startedAt) * 1000
let fields = self.checkpoints.map { "\($0.0)Ms=\(String(format: "%.3f", $0.1))" }.joined(separator: " ")
- DebugLogger.shared.info("CLOSE_DETAIL scope=\(self.name) uptime=\(self.startedAt) totalMs=\(String(format: "%.3f", total)) \(fields)", source: "StopTiming")
+ DebugLogger.shared.debug("CLOSE_DETAIL scope=\(self.name) uptime=\(self.startedAt) totalMs=\(String(format: "%.3f", total)) \(fields)", source: "StopTiming")
}
}
@@ -31,13 +32,13 @@ enum OverlayCloseRunLoopProbe {
private static var observer: CFRunLoopObserver?
static func begin() {
- guard self.observer == nil else { return }
+ guard DebugLogger.diagnosticsEnabled, self.observer == nil else { return }
let state = ProbeState()
guard let observer = CFRunLoopObserverCreateWithHandler(nil, CFRunLoopActivity.allActivities.rawValue, true, 0, { _, activity in
let now = ProcessInfo.processInfo.systemUptime
let elapsed = (now - state.previousAt) * 1000
if state.previousPhase != CFRunLoopActivity.beforeWaiting.rawValue, elapsed > 8 {
- DebugLogger.shared.info("CLOSE_DETAIL runLoop fromPhase=\(state.previousPhase) toPhase=\(activity.rawValue) startUptime=\(state.previousAt) occupiedMs=\(elapsed)", source: "StopTiming")
+ DebugLogger.shared.debug("CLOSE_DETAIL runLoop fromPhase=\(state.previousPhase) toPhase=\(activity.rawValue) startUptime=\(state.previousAt) occupiedMs=\(elapsed)", source: "StopTiming")
}
state.previousAt = now
state.previousPhase = activity.rawValue