clj-fast
clj-fast copied to clipboard
Add instrumentation facilities
Add tools required for trace-timing functions and causal profiling
cc @joinr I think this will interest you. Do you think this should be a separate project?
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?
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
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.
Probably doesn't matter if you dev on it this repo for the time being and choose to move it later though.
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
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.
https://docs.cider.mx/cider/debugging/debugger.html#conditional-breakpoints