Reduce capture and diagnostics overhead - #254
Merged
Merged
Conversation
✅ Deploy Preview for voca-mac canceled.
|
|
| Filename | Overview |
|---|---|
| Sources/VocaMac/Services/AudioEngine.swift | Reuses converters for stable formats and replaces per-sample appends with a bulk operation while preserving mute behavior. |
| Sources/VocaMac/Services/Logger.swift | Introduces locked cross-process log writes, repaired bounded rotation, legacy trimming, and bounded tail reads. |
| Sources/VocaMac/Views/MenuBarView.swift | Limits process monitoring to the visible view lifecycle and releases Mach thread send rights after sampling. |
| Sources/VocaMac/Services/PerformanceTrace.swift | Adds a lightweight signpost abstraction used to measure user-perceived latency intervals. |
| Sources/VocaMac/Services/TextInjector.swift | Instruments clipboard injection through simulated paste without changing injection behavior. |
| Sources/VocaMac/Services/TranscriptionRouter.swift | Instruments serialized model loading and transcription operations. |
| Tests/VocaMacTests/LoggerTests.swift | Adds coverage for bounded chronological rotation, exact cutoffs, oversized files, and Unicode tail reads. |
| Tests/VocaMacTests/ProcessMonitorTests.swift | Verifies repeated process sampling does not leak current-thread send rights. |
| Tests/VocaMacTests/ServiceTests.swift | Verifies converter reuse and replacement along with bulk sample and mute preservation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Audio tap buffer] --> B[Reuse or replace converter]
B --> C[Convert to Whisper format]
C --> D[Bulk append samples]
E[Log event] --> F[Serial file queue]
F --> G[Cross-process file lock]
G --> H{Rotation threshold reached?}
H -- No --> I[Append active log]
H -- Yes --> J[Rotate and trim backups]
K[Resource view appears] --> L[Start process monitor]
L --> M[Refresh every five seconds]
M --> N[Release sampled thread rights]
O[Resource view disappears] --> P[Stop process monitor]
Reviews (2): Last reviewed commit: "fix: preserve log trim boundaries and ve..." | Re-trigger Greptile
Member
|
@Mr-Sunglasses thanks, this looks good. Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Several runtime paths did avoidable work or leaked resources: capture repeatedly reserved exact array capacity and rebuilt its sample-rate converter, process monitoring leaked Mach thread send rights and continued polling while hidden, and log rotation stopped working once all backup slots existed. The active log on the audited machine had consequently grown to about 14 MB, making diagnostic reads expensive.
Changes
task_threadsand poll resource usage only while its view is visibleEvidence
The audit harness measured 60 seconds of capture accumulation at 21.61 ms with exact reservation/sample appends and 0.25 ms with geometric bulk append. At a 600-second stress duration it measured 7,140.10 ms versus 2.94 ms. Reusing the converter reduced a 4,096-frame conversion prototype from 0.0202 ms to 0.0114 ms per buffer. The Mach-port reproduction changed from 4 to 104 send references after 100 refreshes; the fixed form stayed at 3 to 3. Reading the existing oversized log fell from a 117.46 ms whole-file prototype to a 0.84 ms bounded-tail prototype.
These measurements are fixed-device diagnostics rather than CI thresholds. The signposts provide end-to-end evidence on representative machines without making hosted-runner timing flaky.
Validation
swift buildswift build -c releaseswift test— 448 tests passed, 1 environment-dependent Accessibility test skippedHello.; the direct decoder fix is in fix: recover empty short Whisper transcriptions #255.logfiles