How do you profile a Drools app?

How can I know how often the conditions / consequences of each drool are met and how long does it take?

Plain JVM profiles are too low for this purpose, as the names of the internal drooling methods won't tell you which rule they are following.

+3


source to share


1 answer


The question is essentially impossible to answer to assess the condition. Patterns and left-hand constraints are not evaluated by one (in the sense that a Java method is one), but as a network of expressions evaluated in small batches when needed. Moreover, constraints that occur in more than one state can result in the same code, excluding multiple evaluation. The need for an assessment depends on the insertion, deletion and modification of facts; effort varies depending on the values ​​found in these facts. This is all a consequence of the underlying algorithm, originally by Dr. Forgy Reth and in Drools 6.x, Phreaky, which seems to make things even less straightforward by increasing efficiency.

Benchmarking conditions can be done by inserting facts of one class when their field values ​​change and timing (given the usual difficulties Java faces). Note that even this is insidious, since the effort can depend on the current state of working memory, i.e. Fact values ​​of other classes that were inserted. And you have to consider the effort required to restore the original state - leaving the facts in WM will ultimately lead to increased overhead due to memory usage.



The situation is somewhat better for assessing constraints. kaskelotti's note about using an event listener is noteworthy; instead of trying to time these short intervals, just count them. Also note that for many applications, Drools may be good coding practice to implement the right hand side as a (static) Java method: they can be tested (and compared to the results) more easily.

+2


source







All Articles