On Friday, September 5, 2003, at 08:31 PM, Thomas Hawtin wrote:
Dain Sundstrom wrote:On Thursday, September 4, 2003, at 02:01 AM, Sergei Batiuk wrote:
That is not true. A normal Java method invocation on an Object reference (not an interface reference) takes about 3 nanoseconds on my 1g mac. A Java reflection invocation takes about 350 nanoseconds == 0.000 350 ms. My guess is you thing that is slow (and so do I). Instead of using Java reflection we will be using proxies generated by cglib which supports reflective style calls using a MethodProxy object. A reflection invocation using MethodProxy on my 1g mac takes 7 nanoseconds.
I have some issues with your timings there. Are you using the client HotSpot? I get for invocation only around 40 cycles with -server and 440 with -client. For lookup and invocation I get 3,200 with -server and 13,500 -client. Timings on a PII/266 running Linux and Sun JRE 1.4.2, and obviously take microbenchmarks with a pinch of salt. Loops with conventional virtual method invocations can be completely optimised away.
The idea is to get hot spot to optimize the loop so we only measure the cost of an invocation, but if you want to play with it I can send you the code. I really don't understand what you code does, but mine times somewhere 10,000 and 1,000,000 iterations. The number doesn't matter as long as it takes a while. For there I calculate the number of nanoseconds per operation.
Something to be wary of is start up times. IIRC, (server) HotSpot (and I assume equivalent in other modern JREs) compile proxies for Method. Obviously they don't necessarily have to go through byte code, so start up times may be significantly faster.
Startup time is really not a big concern in a long running server (within reason). We just need to be sure that all of the byte code generation happens during the deployment phase.
I'm not saying cglib decisions are wrong, just making sure they're made with appropriate information...
Agree.
-dain
/************************* * Dain Sundstrom * Partner * Core Developers Network *************************/
