New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to profile everything? #124

Closed
kwladyka opened this Issue Jul 31, 2015 · 8 comments

Comments

Projects
None yet
3 participants
@kwladyka

kwladyka commented Jul 31, 2015

I am writing the same same algorithm in a few different ways to find out how Clojure optimize code. To answer myself which way has the best performance.

Is it option to do something like (profile :info :Arithmetic (dotimes [n 100] (my-fn))), but for everything what is running in program? I can do everywhere denfp or add p but... defnp not wroks with highlight text in editor and p make it unnecessary unreadable.

I just want to show most detailed ver. of what happend in program with minimum changes in code.

@kwladyka

This comment has been minimized.

kwladyka commented Jul 31, 2015

Oh i see it doesn't work with nested functions. Does it?

@ptaoussanis

This comment has been minimized.

Owner

ptaoussanis commented Jul 31, 2015

I think you might be misunderstand how Timbre's profiling works. There's an example in the README here.

So profile just enables profiling for the body, and p indicates that you'd like the particular named form to be profiled.

Does that make sense?

I just want to show most detailed ver. of what happend in program with minimum changes in code.

Is it possible you'd prefer something like http://www.yourkit.com/?

@kwladyka

This comment has been minimized.

kwladyka commented Jul 31, 2015

I prefer for this task something what i can have in code permanently, then third part software.

But i understand it is not possible to work with (p :nested fun-nested ...) in another (p :top fun-top). I have many recursion functions and my intention was to see how many times which one was called and how long.

@ptaoussanis

This comment has been minimized.

Owner

ptaoussanis commented Jul 31, 2015

But i understand it is not possible to work with (p :nested fun-nested ...) in another (p :top fun-top). I have many recursion functions

Not sure I follow. What do you mean by "recursion functions"? Approximately how many functions do you want profiling for? Most of your runtime will usu. be spent in only a few functions, the idea's usu. to wrap those with defnp.

A large application may have ~10-20 fns worth profiling, often less than that.

Remember that you can start with high-level wrapping and work your way down to identify hotspots.

So if f1 calls f2, f3, f4, and f5 - you can wrap f1 for profiling and its statistics will include the runtimes of f2 to f5. If it turns out later that you need f1 to be faster and you aren't sure why it isn't, you can start to wrap constituents of f1 (the individual fns for example). But you'll normally only bother to do that when you've identified that the higher-level f1 needs optimizing.

This isn't something that could be done automatically, since only you'll have an intuition about how low-level to go. Auto-wrapping every single fn would just create mountains of noise.

Does that help?

@lkrubner

This comment has been minimized.

lkrubner commented Aug 7, 2015

Since he wrote "find out how Clojure optimize code" I suspect he's looking for a different kind of profiling tool. It sounds like he'd like to look inside of Clojure's core functions and see how they are optimized to run on the JVM, and in particular how Clojure optimizes for recursion.

To kwladyka, I would point out that John Lawrence Aspden managed to do some interesting profiling while using some very simplistic tools. Check out:

http://www.learningclojure.com/2010/09/clojure-is-fast.html

http://www.learningclojure.com/2013/02/clojure-is-fast-is-clojure-still-fast.html

@kwladyka

This comment has been minimized.

kwladyka commented Aug 7, 2015

@lkrubner very ineresting articles, thank you. It is something what i am trying researching myself :)

I have to optimize one algorithm, and i know it is possible to work is faster, because in Scala it works faster. But in Clojure i don't know how to speed it up.

@ptaoussanis also thank you for your profiler and work aroud that :)

@kwladyka kwladyka closed this Aug 7, 2015

@kwladyka

This comment has been minimized.

kwladyka commented Aug 7, 2015

@lkrubner You saved my day (month? ;)) !
I can not express how grateful I am for this artcile :) So happy i have solved it :)

@lkrubner

This comment has been minimized.

lkrubner commented Apr 8, 2016

@kwladyka -- I am glad I could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment