Multi-thread game logic
#1
Hi all. This server is amazing! Thanks for good soft.
I am C++ programmer and I can help you with this project.
As I know , game logic cannot be run on many CPU cores now. I read sources and didn't find anything parallel in it. Is it right?
Chunks can be update independent from each other, so it is possible to make method tick() in cChunkMap parallel. Is it necessary? Does it speed up the server?

Reply
Thanks given by:
#2
You're right that the whole of the server logic isn't threaded at this point but it IS something to look forward to and possibly with a configuration option so people can use all available threads or limit to how many they want (great for GSPs as well).

I myself haven't done much work with threading and with being thread-safe so I can't speak to the code of it much, but any such contributions would be appreciated by most, if not just me.

Cheers.
Reply
Thanks given by:
#3
You're right, there isn't much running in separate threads. A while ago I made chunks generate on a different thread, but it broke things, it created deadlocks, crashes and other bugs and I don't know why Sad If you have experience with multithreading it would be great if you could take a look
Reply
Thanks given by:
#4
(01-24-2012, 10:58 PM)FakeTruth Wrote: You're right, there isn't much running in separate threads. A while ago I made chunks generate on a different thread, but it broke things, it created deadlocks, crashes and other bugs and I don't know why Sad If you have experience with multithreading it would be great if you could take a look
Ok. I have some experience with SIMD multithreading. I think openmp will be good solution here.
There is some little problem with testing. How do you test performance of your server? My test server take only 5-10% of processor and it will be impossible to observe acceleration. I cannot create more clients. Are there any test worlds, or good server commands for it?
Reply
Thanks given by:
#5
In what world is SIMD multithreading? =/

Anyway, you don't have to optimize the server. Like you say it only uses 5-10% cpu, optimizing things would be premature.

Something that you should be able to measure is when the server is generating chunks, it's not responding. You cannot build anything, and pickups don't drop etc. By moving the generation of chunks to a separate thread this is fixed, but it creates lots of bugs ( for some reasonTongue )
Reply
Thanks given by:
#6
I started to move chunk generator and found some problems.
In your parallel version method cWorld::GetChunk returns 0 if there is not chunk and it start to generate it. Returning NULL is not correct because there is no result verification in some functions. Some other functions work incorrect with NULL. GetChunk is safety only with chunk generator in it.
I think that the solution of this problem is generating chunks in other place. Notch server generate 100 chunks near players. MCServer can do the same. On each Tick server will check all chunks near players and add tasks to ChunkGenerator if chunks don't exist.
If I'm right that the main problem is returnin NULL then generating immediate chunks will solve problem.
Did you find other bugs in your parallel ChunkGenerator? I didn't find anything bad.
Reply
Thanks given by:
#7
AFAIK everywhere GetChunk() is used it also checks if it actually gets a valid pointer. There was a deadlock in the code that has recently been fixed, so I think it should work fine now.
Reply
Thanks given by:




Users browsing this thread: 3 Guest(s)