Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-29 Thread Jay Fields
It wasn't very complicated, I just started from zero experience worrying about this stuff. - switch map to loop+recur - add primitive type hints to args and return values - make sure you get the types right (e.g. make sure your longs are longs, not ints) Cheers, Jay On Mar 28, 2012, at 10:17

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-28 Thread endbegin
On Tuesday, March 27, 2012 2:51:41 PM UTC-4, Jay Fields wrote: I recently ran into some code** that was in Java, and ran in single digit microseconds (not millis). I converted it to clojure, and got it running at about the same speed... though it did take me a day to figure out all the

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Cedric Greevey
On Mon, Mar 26, 2012 at 4:03 PM, Daniel Solano Gomez cloj...@sattvik.com wrote: On Mon Mar 26 15:15 2012, Cedric Greevey wrote: What you're running into is the overhead of get the root value of vars like swap! and move-up!.  The only way to avoid this is use something like definline. I

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Armando Blancas
An alternative to the complexities involved may be to write number-crunching hot spots in Java. Thus I'd add to Tip 10 that it ain't so bad if you exploit some JVM-platform-goodness *you* just wrote; by definition it's not much code, it's much simpler and can be done in a functional style. On

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Mark Engelberg
On Mon, Mar 26, 2012 at 3:37 AM, Sergey Didenko sergey.dide...@gmail.comwrote: Hi, I believe I've heard claims that nothing stops Clojure 1.3 code to be made very close to Java in terms of execution speed. My personal experience is that it is very difficult to get Java execution speed. On

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread David Nolen
On Tue, Mar 27, 2012 at 2:18 PM, Mark Engelberg mark.engelb...@gmail.comwrote: On Mon, Mar 26, 2012 at 3:37 AM, Sergey Didenko sergey.dide...@gmail.comwrote: Hi, I believe I've heard claims that nothing stops Clojure 1.3 code to be made very close to Java in terms of execution speed.

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Jay Fields
I recently ran into some code** that was in Java, and ran in single digit microseconds (not millis). I converted it to clojure, and got it running at about the same speed... though it did take me a day to figure out all the tweaks. It can be done, if you're willing to invest the time and learn

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Armando Blancas
You can spot a weak argument when euphemisms and stuff we are yet-to-encounter start to pop up. I find puzzler's experience exactly to mine, point by point, and given the little talk of multi-threading coding in this board I'd expect the same to apply to many others. If anything, the

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread David Nolen
On Tue, Mar 27, 2012 at 3:12 PM, Armando Blancas abm221...@gmail.comwrote: If anything, the java-in-parens gvec.clj *proves* how difficult it is to get Java perf in Clojure. The good real world perf looks a lot like Java, regardless of where you place the parens. So I agree with puzzler, Java

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Armando Blancas
That's a distinction without a difference. I'm saying the host interop overwhelms the cool stuff. That's the kind of code I find foolish to write in product development. I don't advocate going back and forth to Java, but when the host takes over, that's sign that *it* can be the simpler, better

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread David Nolen
On Tue, Mar 27, 2012 at 5:28 PM, Armando Blancas abm221...@gmail.comwrote: That's a distinction without a difference. I'm saying the host interop overwhelms the cool stuff. That's the kind of code I find foolish to write in product development. I don't advocate going back and forth to Java,

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Cedric Greevey
On Tue, Mar 27, 2012 at 5:28 PM, Armando Blancas abm221...@gmail.com wrote: That's a distinction without a difference. I'm saying the host interop overwhelms the cool stuff. That's the kind of code I find foolish to write in product development. I don't advocate going back and forth to Java,

can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-26 Thread Sergey Didenko
Hi, I believe I've heard claims that nothing stops Clojure 1.3 code to be made very close to Java in terms of execution speed. However when trying to match the speed of ad-hoc Heapsort implementation I have faced essential obstacles. Setting type hints and coercions was quite easy. A bit harder

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-26 Thread David Nolen
I suggest examining the examples in test.benchmark to see how Java numeric performance can be attained, http://github.com/clojure/test.benchmark On Monday, March 26, 2012, Sergey Didenko sergey.dide...@gmail.com wrote: Hi, I believe I've heard claims that nothing stops Clojure 1.3 code to be

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-26 Thread Daniel Solano Gomez
Hello, Having given a talk on precisely this topic at Clojure/West, I may be able to give you a couple of hints and explanations. You can find the slides at https://github.com/strangeloop/clojurewest2012-slides/raw/master/Solano-G%C3%B3mez-Crunching-Numbers-with-Clojure.pdf, and I am planning on

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-26 Thread Cedric Greevey
What you're running into is the overhead of get the root value of vars like swap! and move-up!.  The only way to avoid this is use something like definline. I thought that in 1.3 those had been made much faster to access if they didn't have ^{:dynamic true} applied to them? -- You received

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-26 Thread Daniel Solano Gomez
On Mon Mar 26 15:15 2012, Cedric Greevey wrote: What you're running into is the overhead of get the root value of vars like swap! and move-up!.  The only way to avoid this is use something like definline. I thought that in 1.3 those had been made much faster to access if they didn't have