Log in

View Full Version : Am I multi-threading properly? Only 20% CPU usage


zapp7
19th April 2021, 02:14
I have a 3950X (16 physical cores, 32 threads) and I'm running two different scripts. The structure of the first script is:

MPEG2Source
SetFilterMTMode("DEFAULT_MT_MODE", 2)
TFM
TDecimate
QTGMC
QTGMC
Repair
z_ConvertFormat
ImageWriter
Prefetch(31)

I only get around 10% CPU usage with this one.

The second script structure is:

SetFilterMTMode("DEFAULT_MT_MODE", 2)
ImageSource
ConvertToPlanarRGB()
z_ConvertFormat
neo_f3kdb
Prefetch(31)

I run the second script with an HEVC encode using ffmpeg and that only gets around 20% CPU usage.

Is there a way to better optimize the CPU usage or is this a limitation of these functions? I'm using AviSynth+ x64.

Boulder
19th April 2021, 05:22
Did you test using AVSMeter? Encoding to HEVC is not a fool-proof way because the encoder may take a lot of CPU resources and you don't know what the real processing time for the script itself is. On my 3900X with a normal Avisynth script with denoising, resizing and debanding, avs2yuv64 uses 15-30% of CPU and most of the rest go to x265.

Nevertheless, the first script has TDecimate which requires serialized input so it will make multithreading less efficient.

I'd definitely test various values for the number of frames in Prefetch. The best bang for buck for me has been Prefetch(threads=24, frames=10).