Modbder / EssentialCraft3

The update of EC2 for newer version of MC
18 stars 16 forks source link

Enormous Performance Issue with constant config writing/reading multiple times per tick #6

Closed Slind14 closed 9 years ago

Slind14 commented 9 years ago

(latest improvement included https://github.com/Modbder/EssentialCraft3/commit/e662552dc07f8536a8b983ae2732286164f7b420)

Slind14 commented 9 years ago

Taking a close look, it makes me wonder what the reasoning is. The only thing I could think of is to avoid issues with process termination/crashing. Do you mind on sharing the story?

https://github.com/Modbder/EssentialCraft3/blob/e662552dc07f8536a8b983ae2732286164f7b420/java/ec3/utils/common/ECEventHandler.java#L920

Modbder commented 9 years ago

It actually shoud not in any way happen each tick: if(!event.world.isRemote && event.world.getWorldTime() % 20 == 0) look closely at this. This condition only allows configs to be saved every second, not every tick in any way. Also, saving and reading cfg files - especially this small(it really consists of like 3-6 lines) is not a big issue anyway. However it is possible to change the way world events work, I am working on doing so - will also reduce server -> client packet lag. However this issue should not in any way create that much lag... Actually, how many worlds do you have loaded according to the console log? It might be an issue aswell, especially if Mystcraft/RF tools is involved.

Slind14 commented 9 years ago

it's 10 worlds. It is causing this issue during the time a backup is running. If I move the file to ramdisk it would probably be a lot less, but the main thing I'm wondering about is why even save it to disk and why so often? Would it cause issues when it is crashing and therefor couldn't save it on shutdown or last save?

(with multiple times per tick I meant, it is doing more than one save per tick. While this only happens every 20th tick it is still more than 1 on the one tick)

Modbder commented 9 years ago

Well, you are correct here - the thing here is that it is an old code, that needed to get replaced long time ago, but I've kinda forgotten about it. Also, it may be surprising, but in my testing world, there had been like 1000 crashes, and some occured during saving, not even once this saving system has thrown an error... I guess that's why it got left like this, forgotten and never changed to a much better system. Anyway, I have already replaced the system with a new one, let me just quickly test it before committing changes to git ;)

Slind14 commented 9 years ago

:+1: