Fork me on GitHub
#clara
<
2017-11-06
>
souenzzo17:11:51

Can you put a time on each rule? Or a route to view the profile/debug the rules? There is something slow in my engine but I'm not sure how to find what it is.

dadair17:11:03

maybe run your engine under a profiler like VisualVM? can see what methods may be using the most time and go from there?

wparker20:11:00

If the problem is a function in your rules (RHS, accumulator function, etc.) that’s taking a lot of time then something like VisualVM would likely be helpful. That’s where I’d start. If the problem is that the rules are firing in a bad/suboptimal way then Clara’s tracing could provide some info, but that is harder to use. https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/tools/tracing.cljc, the discussion on https://github.com/cerner/clara-rules/issues/344 around potential tracing enhancements could give some insight into how it works as well

souenzzo22:11:10

@wparker I made a macro that wrap rhs inside a time-like macro, that time RHS and store it's time on a global atom (just for use on repl). It allow's me to see how many times each rule is fired, how many time each "burn" takes, avg, "total time" from each rule. Simple and usefull 😄

souenzzo22:11:54

(now I'm using my-ns/defrule in place of clara.rules/defrule)

wparker22:11:51

Glad you’ve found a working solution @souenzzo FYI, there are some cases where Clara could repeatedly add a rule to the queue of things waiting to be fired, remove it, add it again, etc. without ever actually firing it (and thus avoiding that macro) but my guess is those cases are a small though nontrivial minority of perf problems

souenzzo22:11:18

@wparker I'm just trying to find any slow rhs. Insert or not insert, use or not, not matters. I find a single rule that takes 100x more time that any other. I think that not matter if it will be used or not, in this case.

wparker15:11:20

Excellent, sounds like you’ve found your performance problem. 👍

wparker22:11:01

so that sounds like it would work most of the time