[FIXED] cChunkSender
#1
I'm about to add a new thread to MCS, and I thought I might announce it here so that others know what's going on when they run into similar issues that caused me to consider it.

Right now, if a client connects into a world that has been deleted, lots of chunks need to be generated for that user. And the generation process is painfully slow, because the Tick-thread keeps trying to load the chunks over and over again. This actually makes the WorldStorage thread, the Tick-thread and the ChunkGenerator-thread all spin in useless loops - chunk is queued for loading, then attempted to load, which fails, so it is queued for generating, only to find out it's already queued for generating.

On my machine I've observed behavior of 40.000+ threadswitches on each of the three threads.

The real problem lies in the fact that the Tick-thread is using active polling to send outstanding chunks. This is never good. Also IMO the chunks should not be sent in the Tick-thread, because they take time to compress into packets, time that the Tick-thread then lacks.

The best solution that comes to mind is to make (yet) another thread that would wait for the "chunk became valid" event and sending such chunks to clients at that moment.
Reply
Thanks given by:
#2
ChunkSender fully implemented. Finally chunks are compressed in a separate thread, freeing up the TickThread to do only ticks, and removing unnecessary thread-switching in the WolrdStorage thread Smile
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)