View Full Version : x264 only using one core by default
Surtr
21st September 2007, 09:33
I have been using MeGUI and x264 for encoding various things for a while now. Just recently x264 has only been using one of the cores on my Core2Duo (E6300) so the framerate has been about half of what it should be. I have tried messing with the --threads option with no luck. I upgraded megui and x264 and no matter what version I use it seems to only use one core. The only way to get it to use both is to go to Windows Task Manager, right click on x264.exe, go to Set Affinity and enable the second core. Of course after the first pass this gets reset and I'm often asleep for the second pass. Is there any way to fix this? Sorry if it's already been posted. I did search. A lot. I didn't find anything useful though.
I'm currently using x264 ver, 676 and megui 2.6.1012, if that matters.
Sharktooth
21st September 2007, 13:35
:search: :readguid:
In MeGUI settings:
Automatically set number of threads: Some encoders can encode multi-threaded. MeGUI detects the number of threads your CPU works best with and sets it to that. This option is recommended but the optimal number of threads may vary from codec to codec. In particular, for x264 encoding, it's better to leave this option off and manually set the number of threads to 0 in x264 config window (forces --threads auto x264 command line option).
Surtr
21st September 2007, 20:54
I did search and I've read plenty of guides. Searching for stuff like "x264 threads" and "x264 one core" doesn't give any good results. I had a feeling it had been covered, but couldn't find it. Sorry. I know it's annoying when it seems like somebody didn't even bother to try to find the answer.
Anyway, that option didn't seem to make any difference. The profile I'm using has threads set to 0 and if I look at the command line it says --threads auto. It's still only using one core though. Also, AFAIK this didn't happen with an upgrade or anything, just randomly. Why would that option suddenly be checked?
Thank you for your help.
Sharktooth
21st September 2007, 21:39
"Automatically set the number of threads" option must be disabled to use x264 at its best on multicores. however, it seems the problem is not megui but somethin on your system.
Manao
21st September 2007, 21:52
It seems that something on your system forces each program to execute itself only on a defined CPU ( by using the win32 functions SetThreadAffinity / SetProcessAffinity ). I don't think it's related to x264 though. Can you tell us what happens if you launch the encoding from the commandline, specifying --threads 2 or 3 ?
Surtr
21st September 2007, 23:06
It seems that something on your system forces each program to execute itself only on a defined CPU ( by using the win32 functions SetThreadAffinity / SetProcessAffinity ). I don't think it's related to x264 though. Can you tell us what happens if you launch the encoding from the commandline, specifying --threads 2 or 3 ?
Sorry, I forgot to mention that I did try it with just the command line and it does the same thing. I wasn't quite sure if it was x264 or megui that was causing the problem or my system. After googling for a long time I decided I'd ask. I'm at a loss as to what has changed and can't seem to figure out anything I should check.
Dark Shikari
21st September 2007, 23:13
Sorry, I forgot to mention that I did try it with just the command line and it does the same thing. I wasn't quite sure if it was x264 or megui that was causing the problem or my system. After googling for a long time I decided I'd ask. I'm at a loss as to what has changed and can't seem to figure out anything I should check.Actually, I had this same problem a bit ago.
Are you using --thread-input? There seemed to be some strange bug that caused x264 to max at 50% CPU when using --thread-input and --threads 2, if I recall correctly.
Surtr
21st September 2007, 23:40
Actually, I had this same problem a bit ago.
Are you using --thread-input? There seemed to be some strange bug that caused x264 to max at 50% CPU when using --thread-input and --threads 2, if I recall correctly.
Yes I was using it. I actually just found http://forum.doom9.org/archive/index.php/t-101039.html which made it so it'll use both cores again. I'm not sure what the actual CAUSE was though.
akupenguin
22nd September 2007, 09:58
There seemed to be some strange bug that caused x264 to max at 50% CPU when using --thread-input and --threads 2, if I recall correctly.
Very unlikely. "--thread-input --threads 2" is identical to "--threads 2". --thread-input is only needed if you're not otherwise threading the encoder, e.g. if you just want avisynth in one thread and x264 in another.
Dark Shikari
22nd September 2007, 10:00
Very unlikely. "--thread-input --threads 2" is identical to "--threads 2". --thread-input is only needed if you're not otherwise threading the encoder, e.g. if you just want avisynth in one thread and x264 in another.I'll see if I can replicate it.
Edit: Meh, doesn't replicate, probably my own stupidity in the first place anyways.
Manao
22nd September 2007, 11:20
Surtr : what did you do to make x264 behave properly again ? Because the link you gave imho shouldn't work.
morph166955
22nd September 2007, 16:59
can you run x264 from the command line directly to eliminate megui as a possible reason for this problem?
Surtr
23rd September 2007, 09:42
Surtr : what did you do to make x264 behave properly again ? Because the link you gave imho shouldn't work.
I ran imagecfg on x264.exe and told it to run on both cores by default.
can you run x264 from the command line directly to eliminate megui as a possible reason for this problem?
I did. x264 still only used 50%.
Edit: OK, I was wrong.
Manao
23rd September 2007, 09:57
Right now it's looking like I'm going to be changing programs with imagecfgThat's definitely not the way to go. It's just fighting the symptom without caring about the illness.or reinstalling windowsAnd that's a bit extreme :)
May be by googling 'Process Affinity' you'll find something covering the issue you're having. Try also searching for affinity in your registry. Finally what OS do you have ? 200 ? XP ? Vista ? I remember finding something (http://www.ehow.com/how_2056395_set-windows-vista-processor-affinity.html) about affinity and the registry for Vista, but not having Vista doesn't help for testing.
Surtr
23rd September 2007, 11:07
That's definitely not the way to go. It's just fighting the symptom without caring about the illness.And that's a bit extreme :)
May be by googling 'Process Affinity' you'll find something covering the issue you're having. Try also searching for affinity in your registry. Finally what OS do you have ? 200 ? XP ? Vista ? I remember finding something (http://www.ehow.com/how_2056395_set-windows-vista-processor-affinity.html) about affinity and the registry for Vista, but not having Vista doesn't help for testing.
Yeah, I really don't like the imagecfg solution. I ended up being wrong about ALL apps using just one core. I've found some are using both...so it might NOT just be a problem on my side. I've been kinda tired for a week or so and not exactly thinking straight, so my troubleshooting skills have been impaired :(.
I have been googling this for days. The only thing I can find though are people who want to set their programs to only run on ONE core. not vice versa. I'm kinda going crazy here.
Edit: Oh yeah, I'm on XP SP2. I tried searching in the registry. All I found were some entries for NDIS :-\.
check
23rd September 2007, 11:12
Try running with something like --threads 6 or so. Also try a different x264 version.
Finally, you might be seeing weird usage if you have an avs script which is highly complex and only passes x264 one frame a second or something.
Surtr
23rd September 2007, 11:18
Try running with something like --threads 6 or so. Also try a different x264 version.
Finally, you might be seeing weird usage if you have an avs script which is highly complex and only passes x264 one frame a second or something.
I have tried both of those, no luck. Right now it seems like it's a problem with it not wanting to run on both cores, regardless of threads. With --threads auto it will still use up to 5 threads, just on one core. I'm still not sure what decides what cores it's allowed to work on. Other programs seem to be able to allow them to work on two cores, while some don't.
Manao
23rd September 2007, 11:30
Oh yeah, I'm on XP SP2. I tried searching in the registry. All I found were some entries for NDISSame here, but I was hoping you were on Vista and were facing one of its "feature".
Can you list the programs that can "natively" use both CPUs, and those that can't ?
Can you open the process explorer, and check the processor affinity of explorer.exe, of x264 when you're launching it ( without it being modded by imagecfg ), and of other programs as well ?
What antivirus do you have ? Any chance you might be infected ?
Surtr
23rd September 2007, 20:19
Same here, but I was hoping you were on Vista and were facing one of its "feature".
Can you list the programs that can "natively" use both CPUs, and those that can't ?
Can you open the process explorer, and check the processor affinity of explorer.exe, of x264 when you're launching it ( without it being modded by imagecfg ), and of other programs as well ?
What antivirus do you have ? Any chance you might be infected ?
AnyDVD, PeerGuardian, AI Roboform, RSS Reader, Logitech Setpoint, SpyBot's TeaTimer, Trillian, Sunbelt Firewall and all my ATI catalyst programs start off with the affinity using CPU 0 and CPU 1.
Firefox, Thunderbird, Explorer, Notepad, Calculator, Nero, MeGUI x264, and BioShock all start with affinity only using CPU 0.
Manao
23rd September 2007, 20:27
Explorer.exe having the affinity CPU0 is the reason for all the other applications to have the affinity CPU0, since those applications are launched by explorer ( while the others are launched during start up ). If you set explorer's affinity to CPU0 + CPU1, everything else will be launched with that affinity.
Now, you just have to find why explorer's affinity is set to CPU0 ( there I'm clueless )
Manao
23rd September 2007, 21:45
Some very interesting links :
http://forums.2cpu.com/archive/index.php/t-42168.html
http://forums.2cpu.com/showthread.php?s=&threadid=40118&highlight=affinity+explorer
It seems you are not the only one having encountered that issue. It also seems the issue derives from softwares that try to be integrated to window's explorer.
Surtr
27th September 2007, 23:27
Thank you for the help. It seems to be fixed now. I wish I could say I knew what fixed it. My only guess is my changing to explorer.exe to use both CPUs. Why it wasn't "sticking" before and it is now, I have no idea. It seemed to have been fixed as randomly as it was broken.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.