Robert Klemme wrote: > 2006/7/5, Ron M <rm_rails / cheapcomplexdevices.com>: >> An even more interesting example of what JIT compilers >> can do is "dynamic deoptimization" [1,2]. > > Although I too find this very amazing IBM has an even better description of the technique here where they show nice examples of dynamic deoptimization in Java with some benchmarking. http://www-128.ibm.com/developerworks/library/j-jtp12214/ They also have a great conclusion: "So, what can we conclude from this "benchmark?" Virtually nothing, except that benchmarking dynamically compiled languages is much more subtle than you might think." > I'm not so sure about the > "extreme" in the case of Ruby. Since Ruby is a whole lot more dynamic > than Java, too much of this optimization deoptimization might occur > and thus degrade performance. Well, it's great for long running programs (Rails) and bad for short-lived ones. For long running programs you'll end up in a steady-state where all the methods someone never changes can be inlined and all the methods someone changes in subclasses aren't. I have web servers that have been running for 3 years. Surely most classes that did get subclassed or dynamically modified would have done so in the first few months. For example, if someone never touches 90% of the methods in String or Array in a Rails application, it would help quite a bit to apply every optimization technique known including inlining to those. > It's a tradeoff - as always. In this case I think it could be made to always be a win. For example - don't apply the aggressive optimizations until after some period of time (a minute?, a week?, a month?) after the program started running. Of course a simpler way is what Java apparently does -- provide a runtime switch to indicate that something's a long running process. I believe the way the enable the technique is with the server vs client versions of their VM. Here's[1] how Sun describes it: http://java.sun.com/products/hotspot/docs/whitepaper/Java_Hotspot_v1.4.1/Java_HSpot_WP_v1.4.1_1002_4.html