On Thursday, December 13, 2012 12:51:57 AM UTC+11, Marshall 
Bockrath-Vandegrift wrote:
>
> cameron <cdo...@gmail.com <javascript:>> writes: 
>
> >   the megamorphic call site hypothesis does sound plausible but I'm 
> > not sure where the following test fits in. 
>
> ... 
>
> > I was toying with the idea of replacing the EmptyList class with a 
> > PersistsentList instance to mitigate the problem 
> > in at least one common case, however it doesn't seem to help. 
> > If I replace the reverse call in burn with the following code: 
> >   #(reduce conj (list nil) %) 
> > I get the same slowdown as we see if reverse (equivalent to #(reduce 
> > conj '() %)) 
>
> Ah, but include your own copy of `conj` and try those two cases.  The 
> existing clojure.core/conj has already been used on multiple types, so 
> you need a new IFn class with a fresh call site.  Here are the numbers I 
> get when I do that: 
>
 
Ah, I've also been looking at this in the morning and missed that bit.
When I use a copy of conj I get similar results to yourself:
  w/ list-base             : map-ms: 4.0, pmap-ms 0.6, speedup 7.02
  w/ empty-list-base : map-ms: 9.9, pmap-ms 20.4, speedup 0.48
  w/ list-base             : map-ms: 9.4, pmap-ms 20.7, speedup 0.45
  w/ vector                 : map-ms: 4.5, pmap-ms 1.4, speedup 3.28

It does seem that once used on the empty list case conj gets tainted and 
all future list
uses incur a performance penalty. On that basis it would seem reasonable
 to convert the EmptyList uses in core.lang to a PersistentList instance.

Interestingly using a tainted conj with other types doesn't seem to incur 
the penalty
(the last vector in the times above)

If I get time I might look at a protocol based version of conj out of 
interest.

Cameron.

-- 
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