Log in

View Full Version : Is this x264 or just CPU throttling?


RX782
17th June 2012, 20:24
I've been using x264 for a few weeks now on my new laptop with an i7-2670QM. Its stock is 2.20GHz, with Turboboost up to 3.

In the last two days, I've noticed some odd behavior using build 2200 of x264 (through MeGUI and avs4x264mod, though I'm fairly certain MeGUI uses the latter, doesn't it?). I don't recall if this was an issue two weeks ago, because I reformatted after a quick, but necessary encode using what may or may not have been build 2200. Anyway, my AVS script is fairly simple, and I've listed both that and my x264 settings below. I begin with a decent 8-9fps, and full CPU usage. The Turboboost does its work, and pushes the processor to 3GHz. At a seemingly random time (it's different each time. Sometimes an hour, sometimes three minutes), the CPU usage drops to an astonishingly low 12%, but the Turboboost stays at its peak 3GHz, so I'm not under the impression that the CPU has throttled itself to stay cool. In a somewhat related note, the fans also slow down dramatically, since the CPU is under far less load.

I cannot figure out the cause for this drop in performance. As far as I understand, I am using all my cores at first, even if it's not necessary at the AVS level (though it should be), and then the whole system just falls off. I suspected that maybe even Windows is intentionally limiting the process so that the CPU doesn't overheat, but it doesn't do the same to CPU-intensive games, and other demanding software.

Any ideas? Thanks.

SetMTmode(2,4)
MPEG2Source("D:\0079 DVD\0079_01_d2v.d2v", cpu=0)
TFM(pp=0)
TDecimate()
#SMDegrain(tr=2, prefilter=1, refinemotion=true, lsb=true, lsb_out=false)
SMDegrain(tr=2, prefilter=1, refinemotion=true, lsb=true, lsb_out=true)
Dither_convey_yuv4xxp16_on_yvxx()
#Trim(0,2159)
#info

program --preset slow --tune film --crf 18 --deblock 0:0 --ref 8 --no-mbtree --aq-strength 0.8
--subme 9 --partitions all --trellis 2 --psy-rd 0.80:0.15 --no-dct-decimate --no-fast-pskip --input-depth 16 --output "output" "input"

RX782
18th June 2012, 06:30
Interesting, switching to 32-bit mode fixed it. I thought avs4x264 could pipe to 64-bit x264? Also of small note, I ended up doing this through avs4x264 anyway, but forcing it to pipe to standard 32-bit x264, since MeGUI didn't seem to pipe it if you don't turn the 64-bit switch on.

EDIT: Nope, I spoke too soon. Looking at it closer, it seems x264.exe usage drops completely to zero, and the remaining 12% is from avs4x264mod.

Atak_Snajpera
18th June 2012, 09:26
try again without setmtmode

Didée
18th June 2012, 12:20
"You shall not use SetMTmode(2) before the source filter.

You shall use mode 5 before the source filter, and mode 2 afterwards."

i.e.

SetMTmode(5,4)
MPEG2Source("D:\0079 DVD\0079_01_d2v.d2v", cpu=0)
TFM(pp=0)
TDecimate()
SetMTmode(2)
#SMDegrain(tr=2, prefilter=1, refinemotion=true, lsb=true, lsb_out=false)
SMDegrain(tr=2, prefilter=1, refinemotion=true, lsb=true, lsb_out=true)
Dither_convey_yuv4xxp16_on_yvxx()
#Trim(0,2159)
#info

In this case SetMTmode(2) has been placed after TFM+TDecimate, instead of right after the source filter.
(Because TDecimate, loosely speaking, cannot be multithreaded anyway - each thread is waiting for all others' results, hence each thread has to process all frames, hence the TDecimate operation effectively breaks down to single-threaded performance.)

Now, someone tell if Distributor() is needed when piping to x264 ?
(I didn't use piping for quite some time, and don't remember.)

RX782
18th June 2012, 14:06
i.e.

SetMTmode(5,4)
MPEG2Source("D:\0079 DVD\0079_01_d2v.d2v", cpu=0)
TFM(pp=0)
TDecimate()
SetMTmode(2)
#SMDegrain(tr=2, prefilter=1, refinemotion=true, lsb=true, lsb_out=false)
SMDegrain(tr=2, prefilter=1, refinemotion=true, lsb=true, lsb_out=true)
Dither_convey_yuv4xxp16_on_yvxx()
#Trim(0,2159)
#info

In this case SetMTmode(2) has been placed after TFM+TDecimate, instead of right after the source filter.
(Because TDecimate, loosely speaking, cannot be multithreaded anyway - each thread is waiting for all others' results, hence each thread has to process all frames, hence the TDecimate operation effectively breaks down to single-threaded performance.)

Now, someone tell if Distributor() is needed when piping to x264 ?
(I didn't use piping for quite some time, and don't remember.)

Interesting, I must not have paid as much attention the MT docs as I should have! I must admit though, I've been using mode 2 prior to the source for literally years without problem; if there was a problem, it would simply result in a crash. I will try with mode 5 when I get home. Thanks.

MasterNobody
18th June 2012, 18:40
Now, someone tell if Distributor() is needed when piping to x264 ?
(I didn't use piping for quite some time, and don't remember.)
Afaik, no if you send it directly to x264 (my avs2yuv mod do the same. dunno about others). x264 will add it for you if you didn't.
input/avs.c:
if( !strcasecmp( filename_ext, "avs" ) )
{
res = h->func.avs_invoke( h->env, "Import", arg, NULL );
FAIL_IF_ERROR( avs_is_error( res ), "%s\n", avs_as_string( res ) )
/* check if the user is using a multi-threaded script and apply distributor if necessary.
adapted from avisynth's vfw interface */
AVS_Value mt_test = h->func.avs_invoke( h->env, "GetMTMode", avs_new_value_bool( 0 ), NULL );
int mt_mode = avs_is_int( mt_test ) ? avs_as_int( mt_test ) : 0;
h->func.avs_release_value( mt_test );
if( mt_mode > 0 && mt_mode < 5 )
{
AVS_Value temp = h->func.avs_invoke( h->env, "Distributor", res, NULL );
h->func.avs_release_value( res );
res = temp;
}
}

Groucho2004
18th June 2012, 22:15
Now, someone tell if Distributor() is needed when piping to x264 ?
(I didn't use piping for quite some time, and don't remember.)
Quite simple - if the program that is used for piping invokes the "Distributor" call then the call should not appear in the script.

Since there are now so many programs (and mods of existing programs) for this purpose, one has to either get this important piece of info from the documentation or, if in doubt, examine the source code.