Jump to content



Photo
* * * * * 1 votes

PinAffinity - new tool for CPU affinity setting


  • Please log in to reply
51 replies to this topic

#1 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,068 posts

  • Flag: United States of America

  • Favorite Pinball: Theatre of Magic

Posted 13 February 2018 - 11:57 PM

Read all about it here:  mjrnet.org/pinscape/PinAffinity.html

 

In brief, this is a little program you can leave running in the background to control CPU affinity assignments for all running processes.  This can greatly improve VP performance on a multi-core system by giving it a few cores all to itself.

 

I've found CPU affinity tuning to be the most powerful tool for reducing stutter on my own cab.  I was writing about this in the chapter on performance tuning in the new Build Guide, and when I got to the How To instructions, I discovered that I couldn't find any good tools to recommend.  I was formerly using a closed-source freeware program called PriFinitty, but as eventually happens to all closed-source freeware projects, its developer lost interest and the project is long dead.  There are a couple of tools such as Process Hacker 3 that can handle the job, but they're kind of cumbersome to set up.  So I wrote this little tool.  It's designed to do this one job, which makes it limited in scope but very easy and quick to set up.  Source code is on github.

 



#2 Thalamus

Thalamus

    Pinball Wizard

  • Platinum Supporter
  • 4,829 posts

  • Flag: Norway

  • Favorite Pinball: GOT, Alien Star, LOTR, TOM

Posted 14 February 2018 - 12:41 AM

Very interesting mjr !

 

Thank you. I'll try this out tomorrow.


From now on. I won't help anyone here at VPF. Please ask Noah why that is.


#3 Slydog43

Slydog43

    Pinball Wizard

  • Platinum Supporter
  • 3,006 posts
  • Location:Hackettstown, NJ

  • Flag: United States of America

  • Favorite Pinball: Addams Family, All Williams 90's Games

Posted 14 February 2018 - 02:36 AM

Looking forward to see results from cab owners about the usefulness of this program.  Thanks 



#4 Vizzini

Vizzini

    Enthusiast

  • Members
  • PipPipPip
  • 200 posts

  • Flag: United States of America

  • Favorite Pinball: ???

Posted 15 February 2018 - 01:11 AM

Thanks for your efforts mjr. I gave your program a test. Unfortunately, it introduced decreased performance for me. FPS drop nearly in half. I have vsync set to 1 locked at 60fps without PinAffinity. I'm getting about 30 with your default settings. This was on fuzzel's CFTBL 1.1 with both VPX 10.5 beta and 10.4 final. I have a pretty decent setup 1050ti and a late model i5, i think 7400 @3Ghz. I didn't try to tweak any of your settings.

Oh. I was actually playing with CPU priority yesterday with good success. Basically, I went about it by launching vpx with a shortcut with the following parameters: C:\Windows\System32\cmd.exe /c start "vpinballx" /Realtime "E:\Visual Pinball\vpinballx.exe" I couldn't figure out a way to get affinities to stick.

Anyway. Wanted to give you some feedback because I agree with you that this is a promising avenue to potentially reduce some stutter and way to get affinity to stick.

Edited by Vizzini, 15 February 2018 - 01:17 AM.


#5 Thalamus

Thalamus

    Pinball Wizard

  • Platinum Supporter
  • 4,829 posts

  • Flag: Norway

  • Favorite Pinball: GOT, Alien Star, LOTR, TOM

Posted 15 February 2018 - 01:42 AM

I tried this as well. Played for a couple of hours, different tables and I could not see a drop in FPS. I could not see any improvements either. Will be testing it further. Maybe CTBL next, since that was mentioned.


Edited by Thalamus, 15 February 2018 - 01:43 AM.

From now on. I won't help anyone here at VPF. Please ask Noah why that is.


#6 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,068 posts

  • Flag: United States of America

  • Favorite Pinball: Theatre of Magic

Posted 15 February 2018 - 04:18 AM

Unfortunately, it introduced decreased performance for me. FPS drop nearly in half. I have vsync set to 1 locked at 60fps without PinAffinity. I'm getting about 30 with your default settings. This was on fuzzel's CFTBL 1.1 with both VPX 10.5 beta and 10.4 final. I have a pretty decent setup 1050ti and a late model i5, i think 7400 @3Ghz. I didn't try to tweak any of your settings.

 

Interesting.  Clearly this isn't going to help on your machine. :)  The default settings should be optimal for a quad-core i5, so I'm not sure what the negative interaction is.  Maybe there's something else in your system that it's interacting poorly with.  Any chance there's a second process that your VP setup is interacting with when you test, such as a B2S Backglass Server running as a separate .EXE?  That kind of thing would have this effect, and the solution is easy - you put that other thing, whatever it is, in the Pinball group.

 

One more thought: if you actually have a dual-core-with-hyperthreading i5, that would also explain the slowdown.  Hyperthreaded chips appear in Windows with twice the number cores as they actually have.  E.g., Windows thinks my desktop's i7-3770 is an 8-core chip, even though it's actually a quad-core with hyperthreading.  So if you have a dual-core with hyperthreading, Windows will think it's a quad core.  The default PinAffinity settings in this case will be highly counterproductive - they'd produce a slowdown such as you're seeing.  I think there are probably no good CPU affinity tweaks for such a CPU; I think you're going to better off letting Windows do the best it can with the available cores. 

 

You should be able to see the exact Intel part number (it should say "i5-XXXX" somewhere) in your System properties in Windows.  If you can find that number you can look up the specs.  Intel's spec sheets will say "number of cores: X, number of threads: Y".  If it's hyperthreaded, Y = 2*X, and if it's not, Y=X.

 

I didn't think any i5's were hyperthreaded, so that might not be it at all, but there have been so many generations of these at this point that I'm not sure what all the different configurations are.

 

 

I couldn't figure out a way to get affinities to stick.

 

What do you mean, "stick"?  

 

The program only controls affinities while it's running, so if you mean that you want them to stick after it exits, it doesn't do that.   (And you wouldn't want it to - that kind of permanent messing with your system would be really dangerous.)  If you want it to control affinities, you just leave it running in the background.  When you want it to stop messing with affinities, you quit out of it.

 

What am I missing in your thinking?

 

 

I tried this as well. Played for a couple of hours, different tables and I could not see a drop in FPS. I could not see any improvements either. Will be testing it further. Maybe CTBL next, since that was mentioned.

 

Just to clarify, you shouldn't actually expect to see an FPS change one way or the other with affinity settings.  That's not the metric this will affect.  FPS is a total throughput figure; what the affinity settings help with is thread scheduling latency.  You'd never notice such a thing in ordinary computing because it doesn't affect total throughput.  But it can be noticeable with video games because it contributes to stutter - and on my cab, it's pretty much the sole contributor.

 

If you're getting zero stutter already across all games, there's probably not much to be gained by messing with affinities.  If you're getting stutter at any level now, though, occasional to frequent, this might reduce it.  But it won't do it by increasing your FPS rates, just by making those frames more consistently delivered on time.


Edited by mjr, 15 February 2018 - 07:10 AM.


#7 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,068 posts

  • Flag: United States of America

  • Favorite Pinball: Theatre of Magic

Posted 15 February 2018 - 04:31 AM

Oh. I was actually playing with CPU priority yesterday with good success. 

 

Whatever works on your system is great, obviously, but I'm really leery of using process priorities like this.  It's a very blunt instrument that can cause some really weird pathological effects on the rest of the system, especially for a process like VP that's doing a lot of general computing.



#8 ludovids

ludovids

    Enthusiast

  • Validating
  • PipPipPip
  • 181 posts
  • Location:Owego, NY

  • Flag: United States of America

  • Favorite Pinball: LOTR IJ MM TAF Tommy TOTAN TZ

Posted 15 February 2018 - 10:56 PM

Sounds good mjr, I will give it a try.

 

btw, could you add a link to your Build Guide? I tried searching for it, but struck out. Thanks.


Edited by ludovids, 15 February 2018 - 10:56 PM.

ASRock Z270M Extreme4, i5-7600K, 16GB G.SKILL TridentZ DDR4 3200, EVGA GeForce GTX 1070 SC

Samsung 850 EVO M.2, Samsung UN40JU7100 4K playfield, Samsung SynchMaster 2232 backglass, Pinscape on VirtuaPin Plunger Kit v3


#9 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,068 posts

  • Flag: United States of America

  • Favorite Pinball: Theatre of Magic

Posted 15 February 2018 - 11:10 PM

btw, could you add a link to your Build Guide? I tried searching for it, but struck out. Thanks.

 

Here's the direct link:    http://mjrnet.org/pi...e/BuildGuideV2/

 

It's also linked from my main pinball page:  http://mjrnet.org/pinscape/



#10 Vizzini

Vizzini

    Enthusiast

  • Members
  • PipPipPip
  • 200 posts

  • Flag: United States of America

  • Favorite Pinball: ???

Posted 16 February 2018 - 01:54 AM

mjr. I was indeed running B2S server as exe. Changed it and I still see the fps drop with standard. I think you are right about my cpu. It is definitely a i5 7400 under windows system. So this is probably not going to work for me. Thanks for creating it for others though. When I meant I couldn't get affinities to stick, I didn't mean with your program. I was messing around the day before you released with CPU affinities in task manager (I think I put vpinballx.exe to 3 cores and the B2S server to 1) and to my eye it looked better....maybe only in my head....I don't know. I couldn't find a good solution to get those setting to stick, then I saw you posted your program and thought it was exactly what I was looking for! Again, thank you for another contribution to vpinball!
Oh. I should add, I was seeing the fps drop on any table really. I didn't want to leave the impression something was wrong with fuzzel's CFTBL. There is not. I only mentioned the table because it was new and I thought you might want to test on the same.

#11 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,068 posts

  • Flag: United States of America

  • Favorite Pinball: Theatre of Magic

Posted 16 February 2018 - 02:19 AM

I think you are right about my cpu. It is definitely a i5 7400 under windows system. So this is probably not going to work for me. 

 

Huh, according to the Intel spec sheet, that's a true quad-core, no hyperthreading, so it actually should be a good candidate.

 

 

mjr. I was indeed running B2S server as exe. Changed it and I still see the fps drop with standard.

 

One last thing you might want to double-check is that your vpinball EXE is actually listed in the Pinball group.  It matches by the exact filename, so if you have a renamed file or a different version that's not in the list, it'll put it in the "Normal" group and confine it to one core... which would horribly slow it down.

 

What I'd do is launch the game, get it set up and running, and then go through the process list in the affinity window and check what's listed.  See if you spot anything in the "Normal" group that's part of the pinball game - mainly a VPINBALLxxx.EXE variant or B2S process.

 

 

When I meant I couldn't get affinities to stick, I didn't mean with your program. I was messing around the day before you released with CPU affinities in task manager (I think I put vpinballx.exe to 3 cores and the B2S server to 1) and to my eye it looked better....maybe only in my head....I don't know. I couldn't find a good solution to get those setting to stick, then I saw you posted your program and thought it was exactly what I was looking for! 

 

Oh, I get it now!  Yep, that's exactly why I wrote it. :)


Edited by mjr, 16 February 2018 - 02:19 AM.


#12 Vizzini

Vizzini

    Enthusiast

  • Members
  • PipPipPip
  • 200 posts

  • Flag: United States of America

  • Favorite Pinball: ???

Posted 16 February 2018 - 02:34 AM

Interesting. Nothing odd in the pinball group. But, I think we are on to something. It does recognize vpinballx.exe in the pinball group, but affinity says "Unable." My file is named vpinballx.exe.
By the way, B2Sserver is recognized also (exe), but also "Unable."
UPDATE: Got it. Ran as admin and looks to be working. I'll test it out for awhile and report back!

Edited by Vizzini, 16 February 2018 - 02:35 AM.


#13 Slydog43

Slydog43

    Pinball Wizard

  • Platinum Supporter
  • 3,006 posts
  • Location:Hackettstown, NJ

  • Flag: United States of America

  • Favorite Pinball: Addams Family, All Williams 90's Games

Posted 16 February 2018 - 02:47 PM

I think this might help out with X-Plane 11 with Oculus rift, as it does not use mult-cores and stutters quite a lot.   I think I can run most of windows services etc with 1 or 2 cores and leave 1 separate core for x-plane to do its rendering.



#14 Vizzini

Vizzini

    Enthusiast

  • Members
  • PipPipPip
  • 200 posts

  • Flag: United States of America

  • Favorite Pinball: ???

Posted 17 February 2018 - 03:16 AM

Ok. mjr. Did a little testing. Like Thalamus, I'm not sure I can actually "see" an improvement. But, no doubt, it is there! I'm testing with mfuegemann's Champion Pub (Williams 1998) VPX 1.2 now. Ball movement on that table never looked right on my rig...which I hated because it is one of my favorite tables. This is why I basically started playing around with affinity in the first place the other day. Anyway, I just launched the table and F-11ed and let it sit for a bit. With PinAffinity, I see about 54 fps. Without, 43 fps. (I think this is the only table I can't get to sync at about 60 fps.) I know you said we shouldn't see an improvement in fps. But, there you have it! I totally think this might help others with "borderline" specs. I'd be really curious to see if you could cook up a build that could handle PinballX and its processes. I tried to including it to the savedprocess list. But, it struggled with backglass and dmd videos. I'm not sure what it might be using to drive those. Oh. Lastly, perhaps you might want include the need to set as administrator on your website instructions too - to help others quick to test, slow to read, like me.

#15 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,068 posts

  • Flag: United States of America

  • Favorite Pinball: Theatre of Magic

Posted 17 February 2018 - 04:54 AM

Vizzini - it's great that you got this going.  I'm definitely surprised at the measurable FPS increase, but I guess the affinity hinting must help Windows more than I would have thought.  Maybe it's because of the "borderline" specs, as you put it - maybe you're pushing your CPU hard enough that Windows isn't doing a very good job of scheduling the cores by itself.  Under normal conditions it's pretty good at balancing the load, but maybe that starts to break down at high loads.

 

I'll definitely add a note about running in Administrator mode.  I'm curious what's different on your system - usually the Windows security system allows you to change settings for processes you started yourself, without the need for Administrator mode.  Are you launching PinballX from Task Scheduler or something like that, so that it's starting under a different user ID?  That would explain it if so.  Or maybe you have something in the system security settings that's increasing the protection level.  At any rate, I'll add a note about it to the readme.

 

I'll do some testing with PinballX on my system and see what's going on with it. It might have multiple processes that you have to include in the Pinball group to get good performance out of it.  It can be pretty demanding on system resources because of the video and audio it uses, so it's a good idea to get it included in the tweaks.



#16 Vizzini

Vizzini

    Enthusiast

  • Members
  • PipPipPip
  • 200 posts

  • Flag: United States of America

  • Favorite Pinball: ???

Posted 18 February 2018 - 01:56 AM

I don't think I have anything weird with system security...at least nothing I recall setting up. UAC is all the way down to never notify. No special software. Actually, I wasn't having the trouble with getting PinAffinity working with PinballX. I was only using VPX and launched straight from the exe. Thanks for taking a look at integrating PinballX.

#17 Vizzini

Vizzini

    Enthusiast

  • Members
  • PipPipPip
  • 200 posts

  • Flag: United States of America

  • Favorite Pinball: ???

Posted 18 February 2018 - 02:47 AM

Just FYI. I'm not seeing as big of an improvement today. I'm thinking maybe I had more processes going on in the background yesterday.

#18 Onevox

Onevox

    VP Zealot

  • Members
  • PipPipPip
  • 265 posts
  • Location:Virginia, USA

  • Flag: United States of America

  • Favorite Pinball: The Getaway, High Speed II

Posted 18 February 2018 - 12:10 PM

I installed and found PBX to be very laggy, until I added it to the processes list.  It improved, but not sure if that's a good idea for pbx. Also not sure I'm seeing improvement. But I have very responsive action (and a F11 fps average of 139) without it, except Mnemonic, which now I'm thinking is the table. (Maybe reintall) I'm running an i5-2500k with a gtx1060 at 1080. 


_____________________

 

My build: The Joker Poker.

http://www.vpforums....showtopic=37574


#19 Altuve

Altuve

    Neophyte

  • Members
  • Pip
  • 7 posts
  • Location:Alicante

  • Flag: Spain

  • Favorite Pinball: No se...

Posted 06 March 2018 - 10:01 PM

hello, someone managed to make it work with automatic start and ninimizado in windows 10, to not see it screen without having to clik to minimize it. :hmm:


Edited by Altuve, 06 March 2018 - 10:03 PM.


#20 mjr

mjr

    Pinball Wizard

  • Members
  • PipPipPipPipPip
  • 3,068 posts

  • Flag: United States of America

  • Favorite Pinball: Theatre of Magic

Posted 07 March 2018 - 04:19 AM

hello, someone managed to make it work with automatic start and ninimizado in windows 10, to not see it screen without having to clik to minimize it. :hmm:

 

There are instructions for this in the README file included with the download.  Basically:

 

- If you're using a Start Menu "Startup" group shortcut, right-click the shortcut, select Properties, go to the Shortcut tab, find the "Run:" box, and select "Minimized".

 

- If you're using the Scheduled Task approach in the README to run with Administrator privileges, you have to put  /MINIMIZE in the "Add arguments" box where you set up the command for the scheduled task.