Skip to content

Conversation

bsless
Copy link
Owner

@bsless bsless commented Apr 29, 2021

Add tools required for trace-timing functions and causal profiling

@bsless
Copy link
Owner Author

bsless commented Apr 29, 2021

cc @joinr I think this will interest you.
Do you think this should be a separate project?

@joinr
Copy link

joinr commented Apr 29, 2021

Is this an attempt to provide more fine-grained information than criterium, or to enable direct profiling from the repl instead of hooking up visualvm or something external?

@bsless
Copy link
Owner Author

bsless commented Apr 29, 2021

The idea is to provide two things I found I was missing:

  • a tracing timing profiler: let's say I call some -main and it runs for 700ms. If I could instrument all the functions in the project I could see where most time was being wasted quite easily. Visual VM requires hooking up to a running process, not really suitable for a "one-shot" run. I got this idea when trying to analyze leiningen's start-up time.
  • a causal profiler: a more Clojure oriented approach to something like JCoz

@joinr
Copy link

joinr commented Apr 29, 2021

I was thinking about point 2 after I replied. Yeah, having the ability to introspect and profile locally would be very nice. I think you could replicate jcoz at the sexpr level (or get fancier and go into bytecode, maybe with clojure decompiler, to insert virtual slowdowns). w.r.t. original question, seems like more of a profiling lib than a library for drop-in performance improvement. I would probably fork off a new profiling/instrumentation project since there's no obvious coupling with the stuff in here.

@joinr
Copy link

joinr commented Apr 29, 2021

Probably doesn't matter if you dev on it this repo for the time being and choose to move it later though.

@bsless
Copy link
Owner Author

bsless commented Apr 29, 2021

Regarding instrumenting specific sexprs, without a reader macro to pinpoint interesting locations, it would be hard. Slowing down functions inside vars is easy and gets you 90% of the way there, especially if your functions are small

@joinr
Copy link

joinr commented Apr 29, 2021

without a reader macro to pinpoint interesting locations

You can use metadata, sort of like cider's debugger does with #break and #dbg. I think they just use tagged literals.

@joinr
Copy link

joinr commented Apr 29, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants