ProtocolLib

3M Downloads

ditch exceptions in protocollib - protocollib performance issues

gomin1d opened this issue ยท 3 comments

commented

I noticed performance problems when using ProtocolLib on large online (> 100 online per bukkit server)

protocollib uses exceptions for its work. but exceptions are expensive from a performance standpoint. all the more, I see the use of exceptions in protocollib as redundant and inappropriate.

The protocollib plugin always takes 1st place among all plugins and the server core in generating exceptions:
image
image
image
image

how to reproduce the problem? very simple - start the server with the protocollib plugin, you're done :)

here are the possible solutions I can suggest:

  1. rewrite the code to remove exceptions, use different logic instead
  2. cache object-exceptions, not create new ones every time. however, this is impossible in most cases, because some exceptions are generated by reflection
  3. caching of calls to reflection. Why try to get a class / method / field by name every time? if instead you can do it once and cache
commented

thank you for the profiling work!

i think i've identified a fix for the exceptions you're seeing in the 2nd/3rd screenshots. 1st one i think mostly has to do with cancelled packets, which can't really be helped

in the 4th, it looks like your mineland holo plugin is reading an enum that doesnt exist. it makes a call to one of PL's structure modifiers, which runs a converter, which tries to access something that doesn't exist. in that case, i think throwing a null pointer is the right thing to do. unless the plugin expects a null pointer and reacts to it, in which case it probably should use a different API.

(cyberpwn.react.controller.TaskManager.tick() is also generating significantly more NPEs, might be worth looking there)

commented

Just pushed an update that should fix those list converter exceptions

commented

nice. someday I will check again when I update the plugin