Efficient or not?

Discussion in 'Plugin Development' started by ColonelHedgehog, Nov 20, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ColonelHedgehog

    In my EquestrianDash plugin, because I anticipate there to be at least 8 tracks for the multi-track update, I was thinking that it would cause a lot of lag. So to remedy this, would the best course of action be to unload the unused worlds after the desired track is set?
     
  2. Offline

    Wingzzz

    Here's what a world does- eat up memory (RAM). It will only cause lag if something to make something happen (CPU)- i.e, a plugin executing something on a world, block movements, lots of entities being updated, redstone updating, players walking around causing it to load chunks/unload chunks- although for most of the things I mentioned, if there are no players present, those chunks are most likely not loaded, and as such nothing is probably happening other than some code behind the scenes calculating the end result because it has no one to show the process to.

    Now, as for your situation I have no idea because I don't really get what you're saying. If you can elaborate I might be able to give my view on it.
     
  3. Offline

    ColonelHedgehog

    Wingzzz:

    I explain most of what the plugin does the description. Basically, there will be one server with the plugin, and sever tracks, which are worlds. The players will vote for which map they want to play, and the winning map is chosen.
     
  4. Offline

    Wingzzz

    I don't understand the issue then, is it the fact that all worlds are loaded and this is causing a RAM constraint? Having worlds loaded will cause little-to-no lag because they're just idle (based on what you've said), they will just take a bit of RAM. They take more RAM if chunks are loaded (and if chunks are loaded some CPU) but since no one is on those worlds...
     
  5. Offline

    ColonelHedgehog

    I see. I'm just aiming for maximum efficiency here. Would the cost/reward ratio be worse if I unloaded, even though the worlds aren't in use?
     
  6. Offline

    coasterman10

    I would suggest instead to pool the worlds if possible. If the blocks in a track are not going to be altered (or not significantly, where you can use a list of BlockStates to save and undo changes) then you can reuse them and/or create more if more are needed. As for unloading unused worlds, this would be be done on a low-frequency runnable that checks the ratio of open tracks to online players or tracks in use and starts unloading if it finds too many unused. This would have to be tuned by the server owner.

    At that point it would be reasonable to do some profiling on a high-traffic server and see whether you have memory or processor bottlenecks. If you have memory bottlenecks, unload more aggressively. If you have processor bottlenecks, unload less aggressively, and clear out any entities in the worlds being used. Not saving the world would also be helpful as it would turn the world unload operation into being almost completely a memory freeing operation which would allow Java's garbage collection thread to take care of the rest.

    I would also recommend making a void generator and use it for all the worlds to prevent any unnecessary chunks from generating, since that would let the chunks simply have empty ChunkSections internally which would significantly cut the memory usage.
     
  7. Offline

    xize

    ColonelHedgehog
    Hmm its hard to understand what it builds on those worlds like long minecraft tracks? or big structures?

    anyways I think storing those data could make slight lag but not enough to crash a server if the perm cache is good configurated.
    however the worlds have always a vanilla spawn which I believe is a section of chunks who are always loaded so I think if you build on that part you will expect less lag or lag as always with little to no change.

    however if you want to generate something in unloaded chunks there is may a possibility you have to load the chunk then save the world then unloading it again, which kinda could make lag if you would base this in a for loop per chunk for example.
     
  8. Offline

    ColonelHedgehog

    Tracks are essentially just worlds, formatted in such a way that they track the player's horse and count laps. Track = world + a config.
     
  9. Offline

    xize

    ColonelHedgehog
    aha I see your point now.

    additional I would recommend to use the spawn range of that world or maybe a bit enlarged spawn range since you can change that in the server.properties however I'm not sure if it could be done per world if you 'may' would like to keep those chunks loaded instead of load/unloading chunks.

    what probally could make lag though is when players their location are each very seperated which causes to activating more mob spawners and spawning rates, but Im not sure how that would result if you group players only at the spawn radius and also could make them permissionable like they could build or something else.
     
  10. Offline

    ColonelHedgehog

    I have designed it so that only one game is going at a time, and therefore, only one world is ever being used.
     
  11. Offline

    Wingzzz

    Do the servers restart after the game ends? If so- don't bother with the world management, just load the lobby and track when determined.
     
  12. Offline

    ColonelHedgehog

    The server does restart, yes.

    What do you mean? Because all worlds load on server start.
     
Thread Status:
Not open for further replies.

Share This Page