tg icon indicating copy to clipboard operation
tg copied to clipboard

Processes only need steps for large speedup

Open xyzzy42 opened this issue 3 years ago • 0 comments

I measured this as reducing CPU usage from ~78% to ~45%. Almost doubling the speed, which is expected as described below.

Tg processes the audio in a series of steps that double in size: 2, 4, 8, and then 16 seconds long. This is the one to four dots shown in the display.

Tg starts at step 1 (2 seconds) and goes up, stopping if a step doesn't pass. Data from smaller steps isn't used if a larger step passes.

This means when running at a constant step 4 with good signal, CPU usage is almost double what it needs to be, since steps 1-3 are processed and unused and add up to 14 seconds, almost as much as step 4's 16 seconds.

Change this to start at the previous iteration's step. With good signal, only step 4 will be processed and CPU usage is cut almost in half. If the previous step fails, it will try smaller steps. If it passes and is not yet the top step, it will try larger steps.

End result should end up on the same step as before, but get there sooner. It could be slower if the step drops a lot, e.g. from 4 to 0, but this happens far less often than the step saying the same or nearly the same.

I also change the dot display to consistently indicate averaging interval and amplitude measurement. It did both before in an inconsistent way.

See commit messages for more details.

xyzzy42 avatar Apr 02 '21 00:04 xyzzy42