2007年5月17日星期四

Why do you think CGLib proxies are faster than JDK Proxies?

It's fairly common knowledge that CGLib provides a proxy mechanism that is faster than the JDK's built in proxying mechanism. Or is it more of an Urban myth? I decided I was going to be a good citizen and wanted a mechanism where I could quickly switch between JDK proxies and CGLib proxies in a manner similar to the way AOP frameworks typically make this a small configuration change.I found just such a package in oranjestad commons proxy class.What caught my attention was the performance note at the bottom, where the author indicates that in his testing he actually found JDK proxies faster. My first assumption was that this was due to poor implementation on his part but it got me thinking. I had actually never attempted to validate this urban myth before.So a quick search on the web yielded several links that suggested CGLib is faster (most are older):
http://www.devwebsphere.com/devwebsphere/2005/09/cglib_performan.html
http://www.hibernate.org/hib_docs/reference/en/html/performance.htmlOne article actually provides code (independent of the Oranjestad commons proxy):Implement Your Own Proxy-Based AOP Framework.I downloaded the this code and ran it myself. The output on my developer class laptop (IBM ThinkPad T43, Intel 2.0 GHz, 2 GBytes of RAM) was as follows:08:49:21,093 INFO [DefaultAopProxyFactory] CGLIB2 available: proxyTargetClass feature enabled08:49:21,109 INFO [CollectionFactory] JDK 1.4+ collections available08:49:21,109 INFO [CollectionFactory] Commons Collections 3.x availableUnproxied: 559009(ns) 5(ms)cglib: 21374225(ns) 213(ms)Proxy: 16506009(ns) 165(ms)This seems totally consistent with the Oranjestad performance test. So why do we all think CGlib has faster proxies?
Threaded replies
·
Why do you think CGLib proxies are faster than JDK Proxies? by Prodeep Ready on Mon Apr 23 07:20:18 EDT 2007
·
Re: Why do you think CGLib proxies are faster than JDK Proxies? by Valerio Schiavoni on Mon Apr 23 08:42:08 EDT 2007
·
Re: Why do you think CGLib proxies are faster than JDK Proxies? by Howard Lewis Ship on Mon Apr 23 10:09:11 EDT 2007
·
What JDK, CGLib version? by Mileta Cekovic on Mon Apr 23 10:08:43 EDT 2007
·
speed is not the only reason by Abdul Habra on Mon Apr 23 11:06:12 EDT 2007
·
Re: speed is not the only reason by Rod Johnson on Mon Apr 23 11:41:34 EDT 2007
·
Cglib is definitely faster by Bob Lee on Mon Apr 23 12:33:56 EDT 2007
·
Cglib is NOT definitly faster by Prodeep Ready on Tue Apr 24 10:30:43 EDT 2007
·
Re: Cglib is NOT definitly faster by Anjan Bacchu on Tue Apr 24 13:35:09 EDT 2007
·
Re: Cglib is NOT definitly faster by Prodeep Ready on Tue Apr 24 16:31:21 EDT 2007
·
could it be differences in hardware? by peter lin on Tue Apr 24 22:37:49 EDT 2007
·
Re: could it be differences in hardware? by Bob Lee on Wed Apr 25 01:55:48 EDT 2007
·
How about this by Prodeep Ready on Wed Apr 25 14:06:42 EDT 2007
·
Re: could it be differences in hardware? by peter lin on Wed Apr 25 17:40:31 EDT 2007
·
Re: could it be differences in hardware? by Bob Lee on Wed Apr 25 21:21:47 EDT 2007
·
Re: could it be differences in hardware? by Jesse Kuhnert on Wed Apr 25 22:36:05 EDT 2007
·
Re: could it be differences in hardware? by peter lin on Thu Apr 26 19:24:30 EDT 2007
·
Re: Cglib is NOT definitly faster by Bob Lee on Tue Apr 24 13:39:31 EDT 2007
·
Use ASM instead of CGLIB by Przemyslaw Bielicki on Mon Apr 23 16:23:12 EDT 2007
·
Re: Use ASM instead of CGLIB by Eugene Kuleshov on Mon Apr 23 21:11:49 EDT 2007
·
Re: Why do you think CGLib proxies are faster than JDK Proxies? by James Carman on Tue Apr 24 17:46:14 EDT 2007

没有评论: