Solved Plugin slowdown, loading chunks

Discussion in 'Plugin Development' started by kyle1320, Oct 3, 2012.

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

    kyle1320

    Code:
    http://pastebin.com/QH6yYX4P

    Goal of the code:
    Generating lots of chunks (I mean lots of chunks, like tens of thousands) in a new world then unloading them when the ChunkLoadEvent or ChunkPopulateEvent gets called, to make sure they get generated.

    Problem:
    Even though I'm unloading them, it slows down from about 60 chunks / second to around 2 chunks per second.
    With lots of logging, I've noticed the last chunk in each 'section' (if "size" is 64, every 64th chunk key) of the array is not being removed from the hash map because it think it is a new chunk even if it is not. This may be a bug, or something I am doing wrong, and it may or may not be the cause of the slowdown.
    I'd just like some help with fixing the slowdown, I've been trying to fix it for a few days now with practically no success.

    Extra info:
    I've used keys for storing the chunks, because for some reason it wouldn't recognize if the chunk from the event was in the array if I used List<Chunk>.
    Occasionally the listeners will miss the event, so I've added a loop after the loading of the chunks to check that the array is empty. It's not good, especially since I have to parse 2 integers from the keys, but I'm not really worried about that right now.
    Code:
    if (allChunks.size() % size == 0) {
        logger.info("(" + (size - (allChunks.size() / size)) + "/" + size + ")");
    }
    Logs the progress, forgot to add comments for that.

    Thanks
     
  2. Offline

    kyle1320

  3. Offline

    kyle1320

    Bump / Extra info: After even more logging (log all the things!), I've found much of the time it takes is from unloading / saving the chunks. Is there a faster way of doing this?
     
  4. hard disk access time ios always slow, the only things you can do against it is ramdisk/ssd
     
  5. Offline

    kyle1320

    I have an SSD! D: Any way of saving them within the plugin (to ram), then saving it to file at the end?

    EDIT: Nevermind, thought of a way to avoid saving. Solved
     
Thread Status:
Not open for further replies.

Share This Page