View Single Post
Old 22nd February 2019, 00:47   #12  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,079
Quote:
Originally Posted by Atak_Snajpera View Post
Keep in mind that AviSynth MT works better with prefetch equal to number of cores not logical cpus.
A couple more speed benchmarks show that (at least on my machine) the results are different whether you only check the script with AVSMeter, or if you check the overall speed together with an encoder (I use X264 32-bit, the --threads param was not used so all available cores were used by X264).

It happened quite often that the script by itself was faster when using the number of physical cores for prefetch. But the overall speed was always faster when using all cores. (My Core i5 has 2 physical cores plus Hyperthreading, so I used either 2 or 4 as the prefetch values).


I am still thinking of a simple way to translate Myrsloik's formula into an AVS script automatically. My current prefetch command is this:
Quote:
Prefetch(Max(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS")))/2, MIN(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS"))),8)))
This only works if HyperThreading is active, though.
Getting the logical cores is easy, I can use the environment variable NUMBER_OF_PROCESSORS. The problem is getting the number of physical cores.

So far I have come up with this:
The WMIC command can report the physical cores. I found a batch file which will export this value into an environment variable:

Quote:
set PHYSICAL_CORES=0 & for /f "tokens=2 delims==" %%d in ('wmic cpu get NumberOfCores /value ^| findstr "="') do @set /A PHYSICAL_CORES+=%%d >NUL
Then the GetSystemEnv plugin can retrieve this variable.

To run this batch file I could use CallCmd. Haven't tried it yet, but I am not too sure if the environment variable which the batch file creates will be in the same process environment as the AVS script.

Anyone with a better (and simpler) idea?


Cheers
manolito


//EDIT//
After getting some test results from Selur and doing some serious thinking I decided to make it simpler. Going above 8 prefetch threads for AVS+ should only make sense in some rare situations, so I simplified Myrsloik's original algo:
Quote:
max(physical cores, min(logical threads, 8))
to
Quote:
min(logical threads, 8)
This will use the number of logical threads, but only up to 8. This should give good results in most cases. The prefetch command would be:
Quote:
Prefetch(Min(Int(Value(GetSystemEnv("NUMBER_OF_PROCESSORS"))),8))

Last edited by manolito; 22nd February 2019 at 18:42.
manolito is offline   Reply With Quote