Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Dedicating a processor core to a single program  (Read 1895 times)

Illyon

  • Escaped Lunatic
    • View Profile
Dedicating a processor core to a single program
« on: April 05, 2018, 01:38:50 pm »

hello humans (and other).

I've been reading multiple statements about the ability to reserve the processing power of a whole core for Dwarf Fortress (or, generally speaking, any ongoing program). The idea is to let a single-threaded game run on its own unobstructed by other processes.
However, I haven't been able to find a method /how/ to set this. I did see a couple links, but they were on average a decade old and not leading to any noteworthy results - both here and on other parts of the internet.

Considering how I don't plan on multitasking a lot with this PC of mine I don't necessarily require such a function, but it's been bugging me how I can't seem to find an answer. Perhaps I'm just overlooking something obvious.

To go a bit into details, I'm using an Intel Pentium 4405U, a dual-core simulating four logical cores. In the task manager (Windows 10) I have the option to designate any process to run on any of the four cores (by default all of them, of course), but no option to do the reverse: /Excluding/ any other process from the core.

I'll be thankful for any up-to-date answer for this. Is it even possible, does it require an external program to be installed, and is the whole concept actually worth it after all?

Greetings,
Illyon
« Last Edit: April 06, 2018, 11:10:05 am by Illyon »
Logged

Miuramir

  • Bay Watcher
    • View Profile
Re: Dedicating a processor core to a single program
« Reply #1 on: April 05, 2018, 05:10:09 pm »


I've been reading multiple statements about the ability to reserve the processing power of a whole core for Dwarf Fortress (or, generally speaking, any ongoing program). The idea is to let a single-threaded game run on its own unobstructed by other processes.
However, I haven't been able to find a method /how/ to set this. I did see a couple links, but they were on average a decade old and not leading to any noteworthy results - both here and on other parts of the internet.

Considering how I don't plan on multitasking a lot with this PC of mine I don't necessarily require such a function, but it's been bugging me how I can't seem to find an answer. Perhaps I'm just overlooking something obvious.

To go a bit into details, I'm using an Intel Pentium 4450U, a dual-core simulating four logical cores. In the task manager (Windows 10) I have the option to designate any process to run on any of the four cores (by default all of them, of course), but no option to do the reverse: /Excluding/ any other process from the core.

Quick answer: You're not finding a lot of help because what you're trying to do is unlikely to be useful, is not generally supported on desktop OSs, and even if possible would likely actually reduce performance. 

Some links to consider:
Discussion of this with respect to DF a few years ago, in which locking DF to a core made FPS worse as predicted

Instructions on setting Processor Affinity on Win 10, which notes "modifying processor affinity for a particular process or app may cause stability issues, and it will likely degrade the performance of modern multi-threaded apps and games"

Your specific question on StackOverflow, with responses saying that a) you can't and b) it wouldn't help even if you could

Note that (at least some versions of) Windows Server has some abilities to do this sort of thing in very specific cases (look at Receive Side Scaling (RSS), which limits network use of cores, for instance), but AFAIK even there this is not a routine capability or considered useful in most cases. 

Among other things, many (most?) serious work these days is being done in an environment that expects partial or full virtualization and/or fall-over redundancy to be involved; your application may not even be on the same *computer* from one tick to the next, let alone die or core.  Fast-flux scaling applications are what's hot, Dockerized everything is in, and so on.  While I'm not drinking the, er, prickle-berry juice as much as some people on this, I have to admit I've had three problems this quarter that have been more or less solved by using Docker and not worrying about the underlying hardware or even OS any more. 

Side note: are you *sure* about Pentium 4450U, and not 4405U?  I'm not seeing anything on a 4450U in the usual places.  The 4405U was a low-end netbook CPU from 2015 with 2 cores and 4 threads, which matches your comment. 
Logged

CyberianK

  • Bay Watcher
    • View Profile
Re: Dedicating a processor core to a single program
« Reply #2 on: April 06, 2018, 03:40:51 am »

Google says you can do it on Linux
https://stackoverflow.com/questions/13583146/whole-one-core-dedicated-to-single-process/13585364#13585364

Not that it helps much. If you don't run heavy background processes and have at least an i5 or so Windows is smart enough to put the stuff on other threads while DF is blocking one fully. And even if 2% would be used occasionally by something else it would not really make any difference.
Logged

taat

  • Bay Watcher
  • Doesn't notify people when putting them in the sig
    • View Profile
Re: Dedicating a processor core to a single program
« Reply #3 on: April 06, 2018, 09:23:37 am »

Your operating system is actually very good at deciding how to split the cpu's time to get programs to run quickly. In windows, setting df's priority to "high" will pretty much guarantee that other programs won't get in its way.
Logged
Hypothesis: I will kill all dwarves in a horrible fashion

Illyon

  • Escaped Lunatic
    • View Profile
Re: Dedicating a processor core to a single program
« Reply #4 on: April 06, 2018, 11:25:35 am »

Many thanks for your replies.

Quick answer: You're not finding a lot of help because what you're trying to do is unlikely to be useful, is not generally supported on desktop OSs, and even if possible would likely actually reduce performance. 
That already clears up most of what I've been wondering about. Thinking about it, when something doesn't seem possible it may very well be because it's actually nonsense. The links also helped.
 
Quote
Side note: are you *sure* about Pentium 4450U, and not 4405U?  I'm not seeing anything on a 4450U in the usual places.  The 4405U was a low-end netbook CPU from 2015 with 2 cores and 4 threads, which matches your comment. 
I accidentally switched the digits, yes. I typed that from memory and pasted it into a Google search to check, overlooking how modern technology already guessed the processor I was actually referring to. You win this round, Google.


Once again thank you for the replies, in that case I'll try increasing the priority and see how that affects gameplay.
Logged

Canisaur

  • Bay Watcher
    • View Profile
Re: Dedicating a processor core to a single program
« Reply #5 on: April 06, 2018, 12:51:51 pm »

From what you've described it sounds like a dual-core CPU with Hyper-threading.  Even if you isolate a logical "CPU" to DF you're going to end up with other threads using the same core, although as others have said your OS will probably account for this and schedule accordingly especially if you have it on a higher priority.

But if you do go to the effort of isolating DF, you'll need to disable Hyper-threading as well (usually in BIOS) if you really want to use the entire core just for DF.
Logged