On 9/25/12 11:37 PM, Ben Smith-Mannschott wrote:
On Tue, Sep 25, 2012 at 1:53 AM, James Hess <[email protected]> wrote:
Hi experienced clojure gurus,
According to VisualVM 24% of my time is spent in
clojure.lang.Keyword.hashCode. I'm sure I am doing something wrong (i.e. I'm
not blaming clojure's implementation). Is this an indication that I'm using
keywords too much or something like that? Have other people ran into this
problem before, and if so what were you doing that was causing such high
usage and how did you fix it?
Thanks in advance,
Jimbo
Well, you can eliminate the implementation of Keyword.hashCode() as an
explanation for what you're seeing:
public final int hashCode(){
return hash;
}
So, that leaves two possibilities: (1) You're doing something very
unusual in your code, which we can't say since you haven't showed us
any actual code. (2) You're misusing visualvm or misinterpreting the
results.
I'm guessing 2.
Yes, I believe this is a common misunderstanding. VisualVM does sample
profiling by default and since clojure programs tend to use a lot of
keywords the profiler has a high likelihood of sampling when this method
is being invoked. As Ben points out, hashCode runs in constant time and
can't really be seen as a bottleneck. To get a better idea of where
your hotspots are you'll have to have VisualVM (or YourKit) instrument
your code. This takes longer but you will avoid these red herrings. :)
That said, sample profiling tends to work well for me in most cases and
you can filter out methods like this to remove the noise.
-Ben
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en