The running app
Tapeloop is one process. Measured over two minutes with the kernel's own accounting (the source of Activity Monitor's figures), plus leaks, vmmap and sample, with the popover closed:
| Measure | Before tuning | Now |
|---|---|---|
| CPU | 2.2 % | 1.1 % |
| Memory (Activity Monitor's "Memory") | 175 MB at 13 min, growing | 13.4 MB, flat |
| Peak memory since launch | 41 MB | 13.4 MB |
| Threads | 11 | 8 |
| Wake-ups from idle | not measured | 0.1 a second |
| Disk written | 0 | 0 bytes |
| Leaks | about 94 objects a second | 0 |
The audio held comes on top of the 13 MB: about 22 MB per hour per source at the default quality, so the default two hours of both sources is about 89 MB. Almost all of the remaining CPU time is Apple's AAC encoder compressing the two sources. Meeting detection costs nothing between meetings.
What changed
| Change | Effect |
|---|---|
| Every audio callback drains its autorelease pool | Fixed a leak of about 94 buffer objects a second (over 50 MB an hour) |
| The microphone is read straight from Core Audio | No AVAudioEngine: fewer threads |
| 85 ms audio buffers instead of 11 ms | About 8 times fewer audio wake-ups; other apps are not affected |
| The encoder reuses its buffers; level meters are vectorized | No allocation per callback |
| Chunks are stored at their exact size | Memory no longer creeps up over hours |
| Meeting detection listens for Core Audio changes | No polling between meetings |
| Popover, language list and calendar store are made on first use | Launch peak from 41 MB to 13 MB |
| Closed windows free their memory; the popover timer runs only while it is open | Nothing wakes the app while you are not looking |
Stress, soak and leak tests
A test tool drives the real recorder, encoder, buffer, disk spill and exporter with synthetic audio, far faster than real time.
| Test | Result |
|---|---|
| Soak: 4 hours of two-source audio into the default 2-hour buffer | 24 s of CPU per hour of audio (0.66 % of a core). Memory levels off. Saving 2 hours takes 0.1 s. |
| Soak with disk: 6 hours into a 5-hour buffer, 50 MB memory limit | Memory stays at the limit, the rest goes to disk. Saving 5 hours (108 MB) takes 1.1 s. |
| Sponge: 21 formats, empty and huge buffers, NaN and out-of-range samples, timestamps that jump, 200 rounds of concurrent changes | All checks pass, 0 leaks. Found and fixed one bug (setting the clock back). |
| Speech model: load, transcribe 43 s, unload, three times | Later loads 0.02 s; 43 s of speech in 11 to 14 s; memory does not grow across cycles. |
Saving copies the compressed audio without re-encoding, which is why hours save in about a second.
Compared with Rewinder
Rewinder is an open-source instant-replay app for the Mac that records the screen, system audio and microphone. Its performance report was measured on a 64 GB Mac under heavy load. Its video figures are left out, and the comparison is rough: different machines, and its capture helper handles audio and video together.
| Rewinder | Tapeloop | |
|---|---|---|
| Processes while recording | 3: app, capture helper, ffmpeg | 1 |
| App process memory | 33 MB (peak 73), capture and encoding elsewhere | 13.4 MB (peak 13.4) for everything, plus the audio held |
| Audio processing CPU | ffmpeg 26 to 35 % of a core (noise removal, mixing) | 1.1 % to capture and encode both sources |
| Where the buffer lives | On disk: memory flat at any length | In memory: no disk writes; grows with length |
| Disk writes while recording | 0.4 to 1.3 MB/s (mostly video) | 0 |
| Battery | Lowers the video frame rate on battery | No special mode needed at 1 % CPU |
| Microphone processing | Noise removal and gain | None: kept as heard |
| App size | 94 MB | 19 MB (DMG 9.2 MB) |
Lighter in Tapeloop: one process, no disk writes, a small fraction of the CPU of a software audio chain, a smaller app. Better in Rewinder for some uses: a disk buffer keeps memory flat however long it is, and it cleans up the microphone.
Measure your own Mac
Open Tapeloop, let it record for a minute, then from a clone of the repository:
scripts/measure-performance.sh # CPU, wake-ups, disk, memory, threads, leaks
swift build -c release --product TapeloopBench
.build/release/TapeloopBench soak 4 # the soak test
.build/release/TapeloopBench sponge --leaks
The full report, with method and caveats, is in the repository.