Re: Clojure, Java JIT, and inlining

2009-08-12 Thread Richard Newman
> I don't think Vars are thread-local. They're one of the shared > mutable state primitives. They can be defacto thread local if only > used by a single thread but you need a "sufficiently smart compiler" > to notice that. "Vars provide a mechanism to refer to a mutable storage location that

Re: Clojure, Java JIT, and inlining

2009-08-12 Thread CuppoJava
It is my experience also, that inlining gives the greatest performance gain for functions that expect primitive arguments. As Chouser said, doing this eliminates the boxing/unboxing overhead. Here's my take on this: The Java method signatures created by Clojure will always be Objects in order to

Re: Clojure, Java JIT, and inlining

2009-08-12 Thread Chouser
On Wed, Aug 12, 2009 at 3:03 PM, Andy Fingerhut wrote: > > My apologies for the noise if this is well known in the Clojure > community, but I'll ask anyway. > > One of the tweaks to my Clojure benchmarks that people have suggested > for improving performance, and that does help, is changing some >

Re: Clojure, Java JIT, and inlining

2009-08-12 Thread Aaron Cohen
On Wed, Aug 12, 2009 at 4:24 PM, Richard Newman wrote: > >> I may be wrong, but doesn't a typical function invocation involve >> dereferencing the Var holding the object that implements "IFn" and >> calling invoke?  It seems pretty intuitive to me that this would be >> difficult to inline by the J

Re: Clojure, Java JIT, and inlining

2009-08-12 Thread Richard Newman
> I may be wrong, but doesn't a typical function invocation involve > dereferencing the Var holding the object that implements "IFn" and > calling invoke? It seems pretty intuitive to me that this would be > difficult to inline by the JIT, there is a little bit of > synchronization going on every

Re: Clojure, Java JIT, and inlining

2009-08-12 Thread Chas Emerick
On Aug 12, 2009, at 3:59 PM, Richard Newman wrote: >> Is there some reason that the Java JIT is not doing this, with the >> original code using defn, as fast as it works when using defmacro? > > The macro expands into bytecode within the same Java method, rather > than a method invocation. Some m

Re: Clojure, Java JIT, and inlining

2009-08-12 Thread Aaron Cohen
On Wed, Aug 12, 2009 at 3:59 PM, Richard Newman wrote: > >> Is there some reason that the Java JIT is not doing this, with the >> original code using defn, as fast as it works when using defmacro? > > The macro expands into bytecode within the same Java method, rather > than a method invocation. S

Re: Clojure, Java JIT, and inlining

2009-08-12 Thread Richard Newman
> Is there some reason that the Java JIT is not doing this, with the > original code using defn, as fast as it works when using defmacro? The macro expands into bytecode within the same Java method, rather than a method invocation. Some method blocks are too big to inline, and perhaps the JIT

Clojure, Java JIT, and inlining

2009-08-12 Thread Andy Fingerhut
My apologies for the noise if this is well known in the Clojure community, but I'll ask anyway. One of the tweaks to my Clojure benchmarks that people have suggested for improving performance, and that does help, is changing some function definitions to macros. This is in effect inlining those f