Poweruser / MinetickMod

Multithreading and other optimizations for the Craftbukkit Minecraft server (up to version 1.7.10)
GNU General Public License v3.0
31 stars 5 forks source link

Independent Networking Thread? #19

Closed Zilacon closed 9 years ago

Zilacon commented 9 years ago

I have noticed A LOT that when the world thread is overloaded like from world editing it will kick everyone off the server for "Timed Out" when i used MCPC it did this too but when i used TickThreading which separated the network thread on its own independent thread it never happened again. I could world edit a whole world in and no one would get kicked.

Also adding a config option to control the amount of threads on the server would be a great addition, TickThreading had a config option that let you choose the maximum amount of threads.

Like: Bukkit.,yml multithreading: Spawn: worldtick: 3 (Thread for world generation, chunk loading, growth, etc) playertick: 1 (Thread for player movement, location, etc) blocktick: 1 (Thread for block place, break, etc) entity: 2 (Thread for entities) tileentity: 1 (Thread for tile entities) linked: 1 (Thread that helps processing everything.)

This way people can customize the non-busy worlds to run on 1 thread if they want (by setting everything to 0 but the linked thread to 1) or set the threads higher for busy worlds.

Just an idea.

Poweruser commented 9 years ago

A new thread that (partially) takes care of the packet exchange is plausible. What I currently have in mind:

On further world content threading:

I don't want to go further than this for now, at least not before doing some extensive profiling again in order to figure out what parts take too much time. Letting multiple threads do the entity ticks of one world was actually the first thing I had tried at the very beginning, after identifying entities as the most time consuming part. I failed so miserably, all kinds of weird things started to happen. But of course, I didn't have the insight in the server code, like I do now, back then. Giving each world it's own thread was the second try, and I'm so far quite happy with it

Zilacon commented 9 years ago

@Poweruser Glad to know you have thought about the networking threads as well. Because its really annoying when you get disconnected with plugins running like AsyncWorldEdit when you have it set to clear the queue when players disconnect so when you leave the world edit stops >_>

Poweruser commented 9 years ago

Implemented my idea from above: 14026cb in the testing branch v1.7.10_keepAlive A keep-alive packet is sent every 5 seconds, when the main thread is unable to maintain the connections, while doing something else. The only usable thing in the mean time should be the normal chat, every thing else is frozen. Commands won't work during that period and are executed once the main thread has finished his work. The new thread does make no difference between a busy main thread, a deadlocked or crashed server (without shutting down) for now.

A compiled jar of this is in the releases

Zilacon commented 9 years ago

Thanks ill test this tomorrow.

Zilacon commented 9 years ago

Sorry for extremely late reply, ive been using your keep alive build for almost a week. Its been working perfectly with no issues.

I haven't seen those changes applied to your official build, thinking your waiting on my response. I can say its fine to throw it into the official branch.

Id like to grab me a newer version with your new config with this network patch on it, let me know when you have one available.

Thanks again!

Poweruser commented 9 years ago

I haven't seen those changes applied to your official build, thinking your waiting on my response. I can say its fine to throw it into the official branch.

Correct and will do

Poweruser commented 9 years ago

It's up. I also gave it a setting and made it reloadable, so it can be turned on / off without restarting server