Luke Oliff.

TIL: pv shows you what is flowing through your pipes

·TIL·2 min read·Luke Oliff

TIL Tuesday: I was debugging why a pipeline processing audio files through an STT model was taking so long. The pipeline worked. I just had no idea how fast data was moving through it.

Enter pv (Pipe Viewer). It sits between two piped commands and reports throughput in real time.

command1 | pv | command2

For audio processing specifically:

cat large-audio.wav | pv | transcribe --stream

This shows the transfer rate, total bytes moved, and elapsed time. When processing a 200 MB audio file through an STT model, you see immediately if the pipeline is CPU-bound (slow rate) or network-bound (bursty rate).

cat large-audio.wav | pv -r | transcribe --stream
474MiB 0:00:45 [10.3MiB/s]

The -r flag shows the rate. Seeing 10 MB/s tells you the pipeline is moving faster than real-time audio, so the bottleneck is probably the model inference, not the file I/O.

pv large-audio.wav | transcribe --stream

You can also use pv to read a file and pipe it directly. No cat needed. Add -s with the file size for an ETA:

pv -s "$(stat -f%z large-audio.wav)" large-audio.wav | transcribe --stream
 474MiB 0:00:45 [10.3MiB/s] [================================>] 100%

Now you get a progress bar with a percentage and ETA.

What else is pv useful for?

Tar transfers over SSH. Database dumps. Any pipeline where you want to know “is this thing actually making progress?”

tar cf - ./audio-files | pv | ssh server tar xf -

What flags should I remember?

-r for transfer rate, -b for bytes transferred, -t for elapsed time, -e for ETA. Combine them: pv -rte.

Is pv installed by default on macOS?

No. brew install pv. Worth having in every dev toolkit.