Page 1 of 1

Multithread&core "how to get usage of power"

Posted: 25 Dec 2011 19:17
by XaTriX
Hi',

OTTD seems to be one threaded only ("it's debatable" for Rubidium ^^).
Is that correct for the server ? Except the thread for savegame.

We want to use all the power of a quad (or more) processor, to handle hundred of trains and calculs of ECS & IS (& more addons).

[*] Which CPU we've to choose to handle that ?

Exemple :
- Map 4k²
- More than 500 train (and a lot of others)
- ECS (optional)
- IS with many teams
- Daylenght
With a good speed play (regardless of cpu's client)

[*] My second question is : If we use VM to host a debian & ottd game, it'll use all the power of proc ? (ie use all the cores)


Thanks,

XaT

Re: Multithread&core "how to get usage of power"

Posted: 25 Dec 2011 19:45
by Alberth
XaTriX wrote:OTTD seems to be one threaded only ("it's debatable" for Rubidium ^^).
Is that correct for the server ? Except the thread for savegame.
Yes.
We want to use all the power of a quad (or more) processor, to handle hundred of trains and calculs of ECS & IS (& more addons).
So run 4 OpenTTD games at the same time, it's the only way.

OpenTTD is mostly single core, you can wish what ever you like, but it is basically impossible to make it use multi-core and get a decent amount of speed-up.

To do almost any computation, a thread needs read/write access to the big central map data structure, meaning only one thread can run at a time, meaning the other n-1 threads are waiting. ==> no speed up at all.
If you give it more room, you lose deterministic outcomes. That (I am told) gives a good result, but it causes de-syncs in multi-player.

So there you have it. Either run it as single core at the server, or you can use many cores but you'd lose multi-player. We have picked 'single core' for now, which I think is the best option.

Re: Multithread&core "how to get usage of power"

Posted: 25 Dec 2011 23:16
by JacobD88
Ho-Hum, this again... Alberth is correct...

The best thing you can do at the moment is move OTTD CPU-Affinity to permanently occupy a core that sees little use as i wrote HERE some time ago... If you are on a quad core system, use the 3rd Core (CPU2) as depending on your quad core architecture the 4th core may not be the best performing one...

Actual amount of performance boost is debateable, as OTTD is still running on a single core, but if you choose the right core, OTTD should be the only thing using it and not sharing with windows system and background app processes... That's about as good as you are going to get and using the above workaround is extra work for little gain... That said, i still use it on all of my installs and it's reduced the amount of in-game stutter whilst i have background apps running and the FastForward button "on"...

Maybe OTTD could be made to move all threads to a tertiary core, where available, and as a default, but i really don't see the demand or need for this except in certain rare circumstances or you are a FastForward nut like myself...

Re: Multithread&core "how to get usage of power"

Posted: 26 Dec 2011 00:51
by Eddi
that would rather be the job of your operating system to figure out. i doubt there is actually a (cross-platform) way for a program to demand that it be running on only one specific core.