I would recommend that anyone who publishes their results running this code specify what OS, JVM, and version of Clojure they are using. I don't know yet whether OS and JVM version make any difference, but at least on Ubuntu 10.4 Linux, the 64-bit version, and Sun/Oracle's Hotspot 1.6.0_22-b04 JVM (64-bit data model), I have seen _huge_ differences in performance for this program depending upon whether I was using Clojure 1.2, 1.3 alpha1, and 1.3alpha4. A run using 1.3alpha3 is still going on my machine, but performance appears like it may be pretty close to 1.3alpha4.

You can get a few more details in the Excel spreadsheet here, but the results are summarized below:

http://homepage.mac.com/jafingerhut/files/collatz-results.xls

I used -Xmx64m to limit the maximum heap size in all cases, and always used AOT compilation. Note that Clojure 1.3 alpha4 generated and collected about 500 times more garbage than 1.2 did, and took almost 200 times more CPU seconds.

Clojure 1.2: Finished with correct output.

27.2 sec user + 2.2 sec system CPU time, 80 MB max resident set size, GC log showed 484 GC invocations, collecting a total of almost 10 Gbytes of memory across all GC invocations. The maximum heap memory ever allocated after a GC invocation completed was about 2.4 Mbytes (called "Maximum total live memory" in the spreadsheet).

Clojure 1.3 alpha1: Crashed by running out of memory after completing at least 1%, but less than 2%, of the calls to cseq.

281.9 sec user + 10.0 sec system CPU time, 106 MB max resident set size, GC log showed 2934 GC invocations, collecting a total of 32 Gbytes of memory. The maximum heap memory ever allocated after a GC invocation completed was almost 64 Mbytes.

Clojure 1.3 alpha4: Completed with same (correct) output as Clojure 1.2

5338 sec user + 340.1 sec system CPU time, 104 Mbytes max resident set size, GC log showed 252,710 GC invocations, collecting a total of 5.4 Terabytes of memory. The maximum heap memory ever allocated after a GC invocation completed was almost 44 Mbytes.


On Jan 19, 2011, at 5:52 PM, Paul Mooser wrote:

That completes without giving me any error.

I'm using clojure 1.2.0 on OS X 10.6.6, and the JVM is 1.6.0_22.

On Jan 19, 1:42 am, Andreas Liljeqvist <bon...@gmail.com> wrote:
Reposting this from earlier mail about Euler 14.

(defn cseq [n]
  (if (= 1 n)
    [1]
    (cons n (cseq (if (even? n)
            (/ n 2)
            (+ (* 3 n) 1 ))))))

(apply max-key count (map cseq (range 1 1000000)))

Gives a heap error.
cseq is at most 525 elements long.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to