Re: Performance issue with hashing records

2013-02-06 Thread Bronsa
2013/2/6 Christophe Grand > Hi > > On Mon, Feb 4, 2013 at 2:29 PM, AtKaaZ wrote: > >> => (class {:x "a" :y 3}) >> clojure.lang.Persistent*Array*Map >> => (def m {:x "a" :y 3}) >> #'runtime.q/m >> => (class m) >> clojure.lang.Persistent*Hash*Map >> > > huh? that one I can't explain, I'll have to

Re: Performance issue with hashing records

2013-02-06 Thread AtKaaZ
Hi. Thank you. On Wed, Feb 6, 2013 at 10:50 AM, Christophe Grand wrote: > Hi > > On Mon, Feb 4, 2013 at 2:29 PM, AtKaaZ wrote: > >> => (class {:x "a" :y 3}) >> clojure.lang.Persistent*Array*Map >> => (def m {:x "a" :y 3}) >> #'runtime.q/m >> => (class m) >> clojure.lang.Persistent*Hash*Map >>

Re: Performance issue with hashing records

2013-02-06 Thread Christophe Grand
Hi On Mon, Feb 4, 2013 at 2:29 PM, AtKaaZ wrote: > => (class {:x "a" :y 3}) > clojure.lang.Persistent*Array*Map > => (def m {:x "a" :y 3}) > #'runtime.q/m > => (class m) > clojure.lang.Persistent*Hash*Map > huh? that one I can't explain, I'll have to do some research. => (def m (let [] {:x "a"

Re: Performance issue with hashing records

2013-02-06 Thread Christophe Grand
Hi, On Mon, Feb 4, 2013 at 12:13 PM, Paul Stadig wrote: > On Sunday, February 3, 2013 9:56:49 PM UTC-5, puzzler wrote: >> >> In these examples, the map/record is freshly created each time through >> the loop, so caching should not be a factor. >> > > Good point. So maybe it's not the caching :).

Re: Performance issue with hashing records

2013-02-04 Thread AtKaaZ
On Mon, Feb 4, 2013 at 12:13 PM, Paul Stadig wrote: > On Sunday, February 3, 2013 9:56:49 PM UTC-5, puzzler wrote: >> >> In these examples, the map/record is freshly created each time through >> the loop, so caching should not be a factor. >> > > Good point. So maybe it's not the caching :). > >

Re: Performance issue with hashing records

2013-02-04 Thread Paul Stadig
On Sunday, February 3, 2013 9:56:49 PM UTC-5, puzzler wrote: > > In these examples, the map/record is freshly created each time through the > loop, so caching should not be a factor. > Good point. So maybe it's not the caching :). Another factor is that literal hashmaps are actually Persistent

Re: Performance issue with hashing records

2013-02-03 Thread Mark Engelberg
In these examples, the map/record is freshly created each time through the loop, so caching should not be a factor. In fact, later in the thread, AtKaaZ posted an example which demonstrated his timing results when computing the hash repeatedly on the same object. Oddly, the performance of hashing

Re: Performance issue with hashing records

2013-02-03 Thread Paul Stadig
On Sunday, February 3, 2013 1:07:41 AM UTC-5, puzzler wrote: > > I just went through the process of converting my map-based program over to > records, hoping it would improve speed. Much to my dismay, it actually > slowed my program down substantially. With some profiling, I discovered > that

Re: Performance issue with hashing records

2013-02-03 Thread AtKaaZ
ah I see, you're right , which made me think why would memoize allow non-func but then I realized this: => *((memoize {:key 1}) :key)* 1 =>* ((memoize {:key 1}) :ke)* nil this is what I thought I was doing: => *(def g (A. "a" 3))* #'runtime.q_test/g => *(defn f [] g)* #'runtime.q_test/f => *(de

Re: Performance issue with hashing records

2013-02-03 Thread Mark Engelberg
I don't think this particular example relates. Memoize produces a function, so the time spent is really about hashing functions which presumably hashes on the address of the function (or something similar) and never touches the underlying record. In the later example, you are mostly timing the cos

Re: Performance issue with hashing records

2013-02-02 Thread AtKaaZ
ok i like this variant: => (def r (memoize (A. "a" 3))) #'runtime.q_test/r => (time (dotimes [n 1000] (hash r))) "Elapsed time: 342.363961 msecs" nil => (time (dotimes [n 1000] (hash r))) "Elapsed time: 361.66747 msecs" nil => (time (dotimes [n 1000] (hash (memoize (A. "a" 3) "Elap

Re: Performance issue with hashing records

2013-02-02 Thread AtKaaZ
=> (def m {:x "a" :y 3}) #'runtime.q_test/m => (time (dotimes [n 1000] (hash m))) "Elapsed time: 154.650091 msecs" nil => (time (dotimes [n 1000] (hash m))) "Elapsed time: 164.724641 msecs" nil => (time (dotimes [n 1000] (hash m))) "Elapsed time: 150.194984 msecs" nil => (time (dotimes

Re: Performance issue with hashing records

2013-02-02 Thread Mark Engelberg
Clojure 1.5 RC-4 -- -- 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

Re: Performance issue with hashing records

2013-02-02 Thread AtKaaZ
he's in RC4 => *clojure-version* {:major 1, :minor 5, :incremental 0, :qualifier "RC4"} => (time (dotimes [n 1000] (hash {:x "a" :y 3}))) "Elapsed time: 70.037502 msecs" => (time (dotimes [n 1000] (hash (A. "a" 3 "Elapsed time: 5307.93947 msecs" On Sun, Feb 3, 2013 at 8:22 AM, Leona

Re: Performance issue with hashing records

2013-02-02 Thread Leonardo Borges
Are you running these in Clojure 1.5 RC-1 by any chance? That's when I got results similar to yours. In Clojure 1.4, I get this: user> (time (dotimes [n 1000] (hash {:x "a" :y 3}))) "Elapsed time: 5993.331 msecs" nil user> (time (dotimes [n 1000] (hash (A. "a" 3 "Elapsed time: 3144.3

Performance issue with hashing records

2013-02-02 Thread Mark Engelberg
I just went through the process of converting my map-based program over to records, hoping it would improve speed. Much to my dismay, it actually slowed my program down substantially. With some profiling, I discovered that one possible explanation is that (at least in RC4) hashing of records is a