Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Alex Miller
No flame war here, just healthy discussion. :) I don't mean to over-state the benefit; I have not yet found a program where var invocation was actually the bottleneck and in general a lot of these differences are noise compared to the real meat of the code. On Wednesday, August 6, 2014 7:13:01

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Mike Thvedt
I didn't want to start a flame war, I just didn't want people being misled into thinking static vars are a big perf improvement for most code. It's better do use ordinary dynamic vars unless you're sure it will be beneficial for some tight loop somewhere. The usual case is the JIT inlines the v

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Alex Miller
I've compared the hotspot inlining on current vars through volatile reference, lazy vars ala fastload branch, and static calls ala direct branch and indeed the inlining is affected once things get hot. fastload avoids early loads but is ultimately slower. direct is about twice as fast due (I th

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Gary Trakhman
I think that also implies that the JVM can't inline across the fences, so there's another cost. On Wed, Aug 6, 2014 at 3:42 PM, Mike Thvedt wrote: > I don't want to question your microbenchmarks, but I'm not sure you have > the correct interpretation. > > Read memory fences have little to no co

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Mike Thvedt
I don't want to question your microbenchmarks, but I'm not sure you have the correct interpretation. Read memory fences have little to no cost. In particular, read memory fences are a no-op (literally) on x86 unless the cache line is invalidated. On Wednesday, August 6, 2014 5:54:32 AM UTC-5, R

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Ghadi Shayban
Var indirection is not super cheap, as it has a volatile field, which is a memory fence. I have been working on Clojure with invokedynamic, and I have a demonstrable improvement on microbenchmarks. Obviously your application will have IO and myriad other costs, but I just want to echo that it

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Mike Thvedt
Last sentence should be: "I've replaced vars with Java methods in some high-performance cases and found a 0% speedup." On Wednesday, August 6, 2014 5:54:32 AM UTC-5, Robin Heggelund Hansen wrote: > > Just read this blog post about Oxen ( > http://arrdem.com/2014/08/05/of_oxen,_carts_and_ordering/

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Mike Thvedt
It's worth pointing out that var indirection is already cheap in Java--it is generally dominated by IO, memory access, object construction, dynamic dispatch... The JIT compiler will inline any var access if the var doesn't visibly change, and only needs to check one word of memory per var each

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Robin Heggelund Hansen
Perfect explination, thanks! kl. 20:41:56 UTC+2 onsdag 6. august 2014 skrev Reid McKenzie følgende: > > Functions are objects implementing the IFn interface. This interface > defines a set of methods named "invoke" which return an object given up to > 21 arguments. Once the compiler is done em

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Reid McKenzie
Functions are objects implementing the IFn interface. This interface defines a set of methods named "invoke" which return an object given up to 21 arguments. Once the compiler is done emitting any given function, an IFn object has been created. Def is a general operation which creates a value and

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Robin Heggelund Hansen
Don't understand the compiler that well. Could you provide a short description of what is being done? kl. 13:05:40 UTC+2 onsdag 6. august 2014 skrev Jozef Wagner følgende: > > See this WIP branch https://github.com/clojure/clojure/tree/direct > > On Wednesday, August 6, 2014 12:54:32 PM UTC+2, Ro

Re: Clojure 1.7 and invokeStatic

2014-08-06 Thread Jozef Wagner
See this WIP branch https://github.com/clojure/clojure/tree/direct On Wednesday, August 6, 2014 12:54:32 PM UTC+2, Robin Heggelund Hansen wrote: > > Just read this blog post about Oxen ( > http://arrdem.com/2014/08/05/of_oxen,_carts_and_ordering/?utm_source=dlvr.it&utm_medium=twitter). > > In i

Clojure 1.7 and invokeStatic

2014-08-06 Thread Robin Heggelund Hansen
Just read this blog post about Oxen (http://arrdem.com/2014/08/05/of_oxen,_carts_and_ordering/?utm_source=dlvr.it&utm_medium=twitter). In it is mentioned that Rich is re-introducing invokeStatic to achieve a possible 10% performance increase for Clojure 1.7. I couldn't find any information abo