Joapple / Slimefun4

Slimefun 4 - A whole new Experience.
http://dev.bukkit.org/bukkit-plugins/slimefun
GNU General Public License v3.0
0 stars 1 forks source link

CargoNetwork Optimization #2

Open Joapple opened 7 years ago

Joapple commented 7 years ago

Description

Cargo Networks Tickings eats CPU

br45entei commented 7 years ago
We'll need to start by creating a background thread that will update a series of flags, which the server thread, when ticking the cargo network, will check the flags to see what it needs to do, do it in the time allowed(50 * 20 = 1000ms(1 second), 1 server tick must be 50ms or below in total, since the server uses that time for other things, a good value to stay below is 25ms, preferably 15ms, we can use the timings class I created to track this). That way the server thread only performs bukkit api code, nms code, or anything else that must be run on the main server tick thread, and the background thread can handle anything else, such as memory operations, list management, sorting, file reading/writing to disk, http related requests, etc... The background thread class will need to be an actual instance of java.lang.Thread, I can help with this as I have created tick threads before with a fair bit of success if I do say so myself.
galacticwarrior9 commented 7 years ago

Just wondering whether you guys are close to finding a fix to this? I've been following this fork's development for some time in hopes that you may be able to solve the immense lag caused by the cargo network.

Joapple commented 7 years ago

Actually we know what's the issue, we need to multithread and this can take a while, on my server i just disabled the tick part of the cargo, so we don't have any lag at all.

galacticwarrior9 commented 7 years ago

Thanks for the reply. Does the disabling of the tick cause issues with existing cargo systems?

br45entei commented 7 years ago

It just causes the cargo blocks to not update in the world, so there can be some item duplication or un-updated blocks, also some blocks may not respond to players when they use-click, but disabling the tick won't break anything majorly. Jo knows what all fixes we had to implement, I'm not sure myself.

Joapple commented 7 years ago

This version is not safe yet to be loaded on a production server, but i can send you a version with cargo tick disabled, there is no item glitch or anything, players will be able to access cargo nodes config, but they wont move items.

Joapple commented 7 years ago

@galacticwarrior9 If you want, i fixed the repo, you can build it directly, if you want the android part to be limited, please regen your config! http://www.joapple.ca/files/SlimeFun4.jar