When you say it is spending 99% of its time in PersistentHashSet.cons, is
that the time spent in just that method, or the time spent in that method
and the methods that it calls?

Given that (set ...) is one of the first things called by (solve..), and
that its contents are produced lazily by a for comprehension, if you are
looking at the total time spent in PersistentHashSet.assoc, then maybe that
will be particularly slow.  Not that that solves the problem, but I was
wondering if PersistentHashSet.assoc might be a red herring.

Also, out of interest, are you using a sampling profiler, or an
instrumenting one?


Sometimes the built-in hprof profiler is good for this sort of thing:

java -Xrunhprof:cpu=times,depth=4 -Xmx2g -jar
target\chess-clojure-0.1.0-SNAPSHOT-standalone.jar

  - you can use either cpu=times for instrumenting, or cpu=samples for
sampling.

It is nice because the depth parameter lets you find hotspots including a
few steps up the stacktrace (4 in this case).  And you can use Ctrl-\ /
Ctrl-Break / SIG_QUIT to get it to dump the current stats while the program
is still running to see if some methods are getting worse over time.




On Wed, Oct 23, 2013 at 1:36 PM, Paul Butcher <p...@paulbutcher.com> wrote:

> On 23 Oct 2013, at 13:18, Timothy Baldridge <tbaldri...@gmail.com> wrote:
>
> Great! you have a profiler, use that. Find the hotspots, use YourKit to
> find where the .cons is being called from, find things to optimize, and go
> from there. This is exactly the same process I would use any optimizations
> I attempted.
>
>
> I fear I may have failed to convey the question I'm trying to answer.
>
> I'm sure that I could create a faster solution in Clojure - that's not the
> question I'm trying to answer though.
>
> What I'm trying to answer is why the *exact same* algorithm implemented in
> Scala is 1000x faster.
>
> As far as I know, the Scala version of the algorithm creates exactly as
> many sets and performs exactly as many set operations as the Clojure does.
> But the Clojure version is 1000x slower. That strikes me as very strange
> and worth getting to the bottom of?
>
> I have, of course, looked at the result of the profiler. And what it seems
> to be saying is that set operations in Clojure are ruinously slow. I'm not
> sure that I believe that though - I can't think of any reason why Clojure's
> sets should be 1000x slower than Scala's? So I'm asking for the help of
> this list.
>
> Of course, I can't rule out the possibility that I've failed to convert
> the Scala version to Clojure and they're actually implementing very
> different algorithms - but I've had several people look at the
> implementations and confirm that they appear to be the same. Nevertheless,
> if there is a problem there, I'd also be interested to find it as I'm sure
> that it will teach me something.
>
> --
> paul.butcher->msgCount++
>
> Snetterton, Castle Combe, Cadwell Park...
> Who says I have a one track mind?
>
> http://www.paulbutcher.com/
> LinkedIn: http://www.linkedin.com/in/paulbutcher
> MSN: p...@paulbutcher.com
> AIM: paulrabutcher
> Skype: paulrabutcher
>
>  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to