Page 1 of 1
Multicore processors and Oolite
Posted: Thu May 21, 2009 4:38 pm
by Screet
Hi,
Oolite does recognize the 4 cores from my processor, however, looking at the taskmanager, it always appears as if Oolite is only using a single core.
Could it be that the code itself cannot use multicore technology because it's single-threaded?
If so, does anyone know how to change this in Objective-C? I could very well imagine that collision testing could be a separate thread without any problems.
Screet
Posted: Thu May 21, 2009 4:46 pm
by another_commander
The extra cores are used for texture loading. I am not sure if they are also used for sound processing, will have to check the relevant code. But yeah, the bulk of the game is single threaded.
Posted: Thu May 21, 2009 4:54 pm
by Screet
another_commander wrote:The extra cores are used for texture loading. I am not sure if they are also used for sound processing, will have to check the relevant code. But yeah, the bulk of the game is single threaded.
Hmmm. Can you suggest parts of the code where I could have a look at in order to give threaded collision testing a try? I'd expect that this could help pretty much in situations with many objects...I could imagine that this might sometimes skip a possible collision because the objects did move, but then it also did appear to me, playing previous versions of Oolite, that on rare occasions a ship can move through objects if the ship is fast enough anyway.
Screet
Posted: Thu May 21, 2009 5:02 pm
by another_commander
Have a look at OOTextureLoader.m, +(void)setUp method for an example of how threading is done. Another part where threads are detached is in OOLogOutputHandler.m, -(BOOL)startLogging method. These should give you an idea of how it works. But changing the collision code to make it multithreaded is a seriously challenging task. If you are not sure how exactly it must be done, be prepared for some painful debugging sessions (actually, be prepared for painful debugging sessions anyway
).
Having said that, if you get it to work and it is tested enough, I would be more than happy to include a patch in the trunk.