Most efficient way of saving/loading 25,000 blocks

Discussion in 'Spigot Plugin Development' started by TheAwesomeGem, Oct 15, 2016.

  1. I am currently using MySQL to save around 25,000 blocks because they contain some custom data as the metadata is not persistent. However, it takes around 5-10 mins to stop the server. Is there any efficient way of handling this? Like saving block data on nbt or something?
     
  2. First off, make sure you are not doing the saving on the main thread. Second, I would suggest a simple json or yml file since 25k blocks is not that much data. You could also save the instances a .dat format.
     
  3. You could save the data directly to the blocks via nbt tags using nms.
     
  4. how are you saving the blocks? it's probably taking 5-10 minutes because you are doing a lot operations with locations (which loads chunks)

    if it is 25k nodes, then yes it is. i know from experience that parsing that much yml is slow as fuck
     
  5. How would I go about doing that?
     
  6. Make sure you only call select * from table once and just use the results over and over again.
     
  7. Loading is not the issue. It's only when I save. Because it saves all the new blocks. Every server restart, there are like around 5k new blocks to save.
     
  8. Save them in tasks on their own thread. Every 5m or so do an update to the database which will add or change anything need.
     
  9. I'd handle loading and unloading your data when the chunk containing them is loaded/unloaded.

    Possibly do that on a separate thread since else, it might cause quite some lag.
     
  10. A binary file, with 1 byte blockid 1 byte data