directwebremoting / dwr

Direct Web Remoting - Easy Ajax for Java
http://directwebremoting.org
Apache License 2.0
92 stars 61 forks source link

Otimize assertIsNotOnBaseObject for performance #37

Open ratacolita opened 4 years ago

ratacolita commented 4 years ago

assertIsNotOnBaseObject currently depends on throwing exception for its base case, that is, when the method is not one of Object's methods. That is very bad for performance because exceptions are slow in Java when they need to fill the stack trace. image The image shows a flame graph from a application running DRW. A lot of time is spent on NoSuchMethodException initialization.

I have done a micro benchmark of current implementation versus this proposed implementation: image The results above are for the case when the method is not one of Object's methods.

image The results above are for the case when the method is one of Object's methods.

GetMethodBenchmark.zip

mikewse commented 4 years ago

Thanks for your analysis and contribution! We will look into your suggestions in more detail later this year before preparing the next maintenance release.