bsless / clj-fast

Unpredictably faster Clojure
Eclipse Public License 2.0
234 stars 1 forks source link

Add instrumentation facilities #32

Open bsless opened 3 years ago

bsless commented 3 years ago

Add tools required for trace-timing functions and causal profiling

bsless commented 3 years ago

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

joinr commented 3 years ago

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 commented 3 years ago

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

joinr commented 3 years ago

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 commented 3 years ago

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

bsless commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

https://docs.cider.mx/cider/debugging/debugger.html#conditional-breakpoints