Fork me on GitHub
ghadi03:08:27 @andy.fingerhut HotSpot doesn't currently perform useful optimizations on loops with a long trip count


That's a good point but I don't see how this explains the observed performance difference. Isn't the loop variable long in both cases (as Andy observed)?


Yeah, I do not think that fact fully explains what is going on. I have hacked Clojure to allow an int primitive loop variable, and JIT can compile it to even slower code than the first iteration faster version with a long (but still faster than the 2nd and later iterations)