Thread ownership of a World
|
06-10-2013, 05:55 AM
Anywhere a SetBlock, GetBlock or FastSetBlock is called on a cWorld object.
The point is, anything that is in the tick thread already has direct access to the chunk data, so those methods in the cWorld class are de facto the interface you're trying to create.
06-10-2013, 06:07 AM
I don't understand what you're saying.
I think most accesses to the chunkmap are already done from from the Tick thread? With my solution the special cases that try to access the chunkmap from a different thread use the RunOnTickThread() function and we can get rid of all the CriticalSections. This should increase performance (though perhaps small) because no CriticalSections are being used and it makes it clear that the chunkmap can only be accessed by the Tick thread.
06-10-2013, 06:28 AM
It wouldn't increase performance at all.
Currently, the tick thread locks the chunkmap's CS, performs whatever it needs to, releases the CS, and waits for the next tick; the other threads can interact with the chunkmap. In your version, the tick thread performs whatever it needs, then it locks the commandqueue's CS, executes the commands, releases the CS and waits for the next tick. There's nothing saved and nothing gained; but it gives additional complexity and additional burden on the tick thread.
06-10-2013, 06:54 AM
Oh right, you changed all that. Now the entity tick function gets a chunk reference. Hmm..
06-10-2013, 02:36 PM
Yup, all the tick functions receive a chunk reference, so that they can both access it directly (without locking - the tick thread already holds the CS) and don't need to search for it in the chunkmap's layers.
07-06-2013, 04:41 AM
I'm currently having thoughts very similar to what you must have had when you wrote your initial post. The threading in the server has gone a bit out of hands, especially with all the deadlocks lately.
07-06-2013, 06:21 AM
Would a single-threaded problem fix deadlocks?
07-06-2013, 07:13 AM
Going back to single-threaded is both impossible and impractical - you'd lose performance on multi-core machines, and there's already so much code written dependent on the multithreading that we'd have to rewrite half of the server from scratch.
But still, there are a bit too many threads with not really well defined boundaries between them. We could definitely improve on that.
07-06-2013, 07:43 PM
Perhaps you can some way visualize how threads and data interact with each other and come up with a solution from that.
Personally I have not had any training for visualizing relations in code, do you perhaps know anything about this? |
« Next Oldest | Next Newest »
|
Users browsing this thread: 8 Guest(s)