Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.7.0.pre1
-
Fix Version/s: JRuby 1.7.0.pre2
-
Component/s: Compiler, Performance
-
Labels:None
-
Number of attachments :
Description
There appears to be a rather severe degradation in performance on the Ruby-based Time.strptime when running on JRuby master with invokedynamic.
Java 7 without invokedynamic: Time.strptime 65.929000 0.000000 65.929000 ( 65.930000) Java 7 with invokedynamic: Time.strptime 196.221000 0.000000 196.221000 (196.221000)
I investigated a bit. The offending method is eventually Date._strptime_i in date/format.rb. It's a pretty dreadful method...very large, with a giant case/when statement with String cases. It appears that it is actually compiled by the JVM JIT, but it's so large I'm sure many of the dynamic calls are not inlining. I suspect that because non-inlined invokedynamic calls are still very slow, performance suffers.
This lends some weight to building in a tiered failover that would limit invokedynamic use to smaller methods, failing over to normal CallSite invocation and eventually full interpretation. The compiled version using our simpler inline caching logic manages to perform around 3x faster...a vast margin.
The benchmark is here: https://gist.github.com/1586648
Run with --1.9, since it uses strptime from 1.9's time/date libs.
It's worth mentioning that 1.9.3 actually implements this as a C extension, so that would be a perfectly fair option for us.