Updating a plugin.. Plugin causes server to lose over 13 TPS!!

Discussion in 'Spigot Plugin Development' started by Justin393, May 24, 2015.

  1. Hey everyone, so I'm trying to update the plugin BlockHunt http://dev.bukkit.org/bukkit-plugins/blockhunt/ to 1.8.3 so I can use it on my server. I got it running, but after about 2 minutes of it running the server drastically drops in TPS until no one can move. I managed to get a timings report of it http://timings.aikar.co/?url=11318876 As you can see the Pct Total for BlockHunt alone is 95.35% and the tick is over 10,000

    The source code of the plugin can be viewed here https://github.com/Steffion/BlockHunt/

    I have narrowed down what I believe to be the cause of the lag to a a repeating task inside of the onEnable() that's set to execute every tick and loop through every arena. If this is the case does anyone have any suggestions to make it not lag? Here's the problematic code (That I think it is, could be something completely different) http://hastebin.com/osahulovak.avrasm

    So if anyone has any ideas, please help
     
  2. Omnivion

    Patron

    Went ahead and updated it to 1.8 from their master branch on github: http://pastebin.com/raw.php?i=TUk95cL8 (patch file compared from their public stable version). I don't remember seeing anything in there needing to be updated to 1.8, but I did do some stuff like ripping out metrics. Have fun.
     
  3. Like I said, I already got it updated (all I had to do was recompile with new versions of stuff) I also took out metrics, but that didn't answer my question on why it lags. Did you even fix the lag?
     
  4. Omnivion

    Patron

    Try my patch and see if it still lags. Tbh, I've got no clue what the plugin is even supposed to do, I didn't even bother running it :p
     
  5. It sounds like you did the exact same thing I did. And how do you not know what BlockHunt is? o.o
     
    • Funny Funny x 1
  6. Still haven't figured this out, any suggestions.
     
  7. In scoreboard, change from offlineplayers to string, because Offlineplayers connect to mojang every single time...
     
    • Informative Informative x 1
  8. Alright, thanks, but I feel like I can do more to fix up the lag. Anything else you see? I will definitely do your suggestion.
     
  9. Replace Players from store with String, is better way, and no possible leaks!
     
  10. Exactly where are you finding these? Would you mind putting Class/Method name/ line numbers? Sorry, but I'm on my phone right now so I can't search and entire page :/
     
    • Agree Agree x 1
  11. Why you tag me without read above? I said to Justin to replace with string :)), and by the way these values seems to not be saved in config, so uuid is not necesary
     
  12. Doesn't matter if it's not saved in config. Strings are still a bad idea for players...
     
  13. So find every instance of a player being stored to something and change it to UUID?
     
  14. Yes, and when you need a 'Player' object use Bukkit.getPlayer(UUID);
     
  15. Alright, thanks guys, but back to the code from the onEnable I referenced in the OP. Would that cause any noticeable lag by looping through every arena every tick?
     
  16. So I implemented fixes, and it doesn't lag anymore, but I have some problems. When I change the Scoreboard from Bukkit#getOfflinePlayer() to Bukkit#getPlayer() it generates a NPE, but when I use Bukkit#getOfflinePlayer() I lose over 8 TPS. Also I can no longer create an arena after I changed it to storing a UUID in the HashMap instead of a Player. Here is the error: http://pastebin.com/tMvyM2ud

    Here is the class for creating an Arena: http://hastebin.com/ikupigeyey.avrasm
    Here is W.java: http://hastebin.com/evumirebiz.java
    Here is ScoreboardHandler.java: http://hastebin.com/vejipiwoju.avrasm
     
  17. If you clean up when they quit, there's no leak either.