ditch exceptions in protocollib - protocollib performance issues
gomin1d opened this issue ยท 3 comments
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:
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:
- rewrite the code to remove exceptions, use different logic instead
- cache object-exceptions, not create
new
ones every time. however, this is impossible in most cases, because some exceptions are generated by reflection - 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
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)