oracle-samples/clara-rules

Create function that uses tracing to return rules with potential performance problems

Closed this issue · 2 comments

Currently we have tracing functionality that contains abundant information about the flow of data through the session. When rules sessions experience performance problems this tracing can provide information on what rule(s) need to be optimized. However, this information is difficult to interpret; often significant knowledge of Clara's internals is required to do so. The full trace necessarily contains the richest information, but it should be possible to provide utility function(s) that provide a quick snapshot of what rules are likely to be performance problems in simple cases. I envision something along the lines of:

  • Create a map of node IDs to the count of operations on these nodes.
  • Associate each node ID with the rules and queries that it feeds into.
  • Return some data structure representing rules/queries with associated counts. For example, we could return a list with entries like [rules-and-queries-names-list node-type-keyword interaction-count], one entry per node with an ID, in descending order based on the interaction-count.

The objective of this would not be to represent all the information available in the tracing, but to provide a rough snapshot. My experience is that in practice many rules performance problems are revealed by analysis of rules traces at this level. For example, rules that are simply provided with a large amount of data, a small number of rules that repeatedly create work for each other, etc. I'd like the interface to be simple enough that it could be used in logging to log out something to the effect of "Experienced a potential performance problem in rule X with maximum interaction count N". It should be noted that full tracing needs to be turned on for this to be possible; under what circumstances the performance consequences of this are acceptable will vary depending on the use-case.

Pull request at #416

Closing issue since I've merged the PR