Fork me on GitHub
#clara
<
2017-09-01
>
mikerod14:09:21

Well, I know Drools (popular Java-based rules engine)(prior to v6) used to have a good amount of performance issues around accumulators.

mikerod14:09:28

Especially several in a rule

mikerod14:09:56

so people used to wish that salience would “delay” their evaluation

mikerod14:09:26

Later on, a lot of laziness was added to Drools, but even more importantly (in my opinion) “batched” propagations of facts and it mostly solved the common issues around performance that came up.

mikerod14:09:47

Clara has “batched” propagation of facts, which seems to typically work out well. The engine basically “gathers” up collections of facts at a time that are matching conditions before propagating down the network. This results in typically less churn/rework as the data flows.

mikerod14:09:13

Just pointing that out if the question of salience was more about performance than ordering semantics

dadair18:09:21

I'm not sure if this is directly tied to clara, but I am noticing a severe processing time drop the first time I run a rules session with a specific namespace. So for example, (-> (r/mk-session 'some.ns) (r/insert ..) .. (r/fire-rules)) takes 1000ms the first time it is called, but 50ms the second time. Is there some way I can reduce that first performance hit?

dadair18:09:28

I know I need to profile the app to be sure what's going on, just darn jprofiler is too expensive >.<

mikerod19:09:23

@dadair well, you can use visualvm for free

mikerod19:09:34

which I’ve had enough luck with when profiling rules before

mikerod19:09:23

Oh, r/mk-session creates and then caches the rulebase (Rete graph)

mikerod19:09:46

Can you (r/mk-session 'some.ns) sometime earlier - like “startup”?

mikerod19:09:25

You’ll still take the hit though. Just maybe you could move the hit out of the processing where it is more painful.

dadair19:09:07

awesome thank you, that will solve my issues (and thanks for the nudge at visualvm, looks good too!)

dadair19:09:01

@mikerod if I different collections of ns (i.e., (r/mk-session 'ns.a 'ns.b 'ns.c) vs (r/mk-session 'ns.d 'ns.e 'ns.f) can I pre-cache individual namespaces e.g. (r/mk-session 'ns.a)? Or would I have to pre-cache full collections (r/mk-session 'ns.a 'ns.b 'ns.c)? Basically, can I init each individually, if they are used in collections? Or will it only cache on the full collection.

mikerod20:09:19

@dadair glad you can work with that. Building the rulebase graph can be a fairly expensive operation. It could perhaps be further optimized in Clara, but there are tricky aspects.

mikerod20:09:42

For one, there is some eval going on, which means it is running the clj compiler and I often see that time dominate for larger rulebase’s

mikerod20:09:15

(terminology things: the “rulebase” term just means the underlying “statess” Rete-based graph that is wired together with working memory within the “session”)

mikerod20:09:36

To answer your next question, you have to build the r/mk-session with all rules/queries involved at once

mikerod20:09:42

Can’t build piece-by-piece

dadair21:09:41

ok great thank you @mikerod