From: Charles Oliver Nutter Date: 2008-06-02T07:18:52+09:00 Subject: Re: Huge performance gap Roger Pack wrote: > Charles Oliver Nutter wrote: >> What does make a huge difference for JRuby is eliminating some of the >> extra overhead related to rarely-used Ruby features. For example, the >> difference between a normal run and a run that eliminates an unnecessary >> frame object, uses fast dispatch for math operations, and eliminates >> some thread checkpointing: > > Maybe something is possible along the lines of > > vm_optimized :no_frame_pointer, :fast_math, :no_thread_checkpointing do > # some code that should run very fast > end A flag is problematic for a couple reasons: - Most of the optimizations I'm trying to specify are not compatible with everything in Ruby; when enabled they'll limit available features to a subset that doesn't incur as much runtime overhead (and this is overhead both JRuby and MRI contend with). - For the cases where there are optimizations that can be applied globally...we just spin a new release and apply them globally. There's not really a need to hold back on such things if they don't break Ruby. Ideally, we'd be able to apply these optimizations everywhere they'll be safe automatically, but that's a very hard problem with Ruby's dynamic nature. So I see these as more a "programmer promise" that they won't use certain higher-overhead features in exchange for better performance. It's not something I'd see a lot of people using for general apps, but it might be useful when building JRuby internal or core framework code. I'm open to all thoughts on this though. There's lots and lots of things we can optimize by incrementally shutting down particular features. And I think it's a reasonable choice to offer people...if you want something faster and are willing to give up a little, it should be your choice. And yes, I fully appreciate the compatibility aspect of this...so it's definitely not intended for the uninitiated and probably not for general use. - Charlie