Performance Issue in EntityNMSArmorStand.getId()
oloflarsson opened this issue · 8 comments
https://gyazo.com/9799947dc733f746a41e753e510ad2f9
9b539eb#diff-f20cadd857d669eb531ee495e6d3d16bR115
Getting the stack trace at that line causes lag spikes according to my in development lag cause detector plugin MassiveLag.
Solution Suggestions:
- Would it be possible to inject modified versions of "EntityTrackerEntry" instead?
- If not then maybe use
(new Throwable()).getStackTrace();
instead for a slight performance improvement (http://stackoverflow.com/questions/2347828/how-expensive-is-thread-getstacktrace).
Sorry, I've been inactive for a while. Someone should try removing all the getId() workaround and see if constantly teleporting a hologram works smoothly and doesn't misalign lines.
I'm not sure your plugin is correct: according to the stackoverflow page, it should take only ~0,003 ms for each individual call.
I cannot overwrite the entity tracker, it would collide with ProtocolLib and similar plugins probably.
My guess is that getting a stack trace takes much longer time when parallel threads are getting stack traces too. I was running VisualVM which samples all threads and MassiveLag which does too. Getting a stack trace is thread safe. In such situations there might be extra overhead?
Anyhow, here is another output from the plugin:
https://gyazo.com/7362441259df88bdbd87733d5b3163a9
I had the analyzer run over night. Turns out it's still using 5.20% of main thread time.
My MassiveMobs plugin places loads of holograms and mob name plates. If you have enough holograms even 0.003 ms starts adding up. Once a tick the nameplates are moved in position.
0.003 ms is actually quite slow. Compared to say System.nanoTime
which takes 20-30 nanoseconds.
Here is a better solution for you:
https://github.com/filoghost/HolographicDisplays/blob/master/HolographicDisplays/Plugin/com/gmail/filoghost/holographicdisplays/nms/v1_8_R3/EntityNMSArmorStand.java#L185
At that line do a manual construction of the packet with the actual id and don't do the stack trace check.
Thanks for the solution, however most of the time holograms are just being showed to players. It wouldn't solve the problem entirely.
Awesome. When will you release the next version? I'm really eager to benefit from this performance improvement 😸.
I tried to compile myself but I failed. There's a lot of different NMS versions referenced making it hard. Could you compile and release a plugin update, please? Or just send me a compiled jar please? My skype is olof.olle.larsson
if you want to add me 😸.
Finally fixed in 1.11 (holograms are perfectly in sync with the client) 1a6c99c