LexQLexQ
Back to blog
rule-engineperformanceobservabilitylatency

Per-Rule Latency: The Measurement That Rule Engines Leave to You

A trace tells you the decision was slow but not which of the rules inside it was, and none of the seven rule engines whose documentation was surveyed computes rule-level percentiles itself.

Sanghyun Park·August 20, 2026Updated November 19, 202613 min read

A quota check runs in front of every request a SaaS product serves. One Tuesday its p99 goes from 9ms to 26ms, and the graph that catches it is the graph every team has: an APM trace with a span named policy evaluation, sitting between the auth span and the first database call, three times wider than it was the week before.

That span is where the investigation stops. It covers a ruleset that reached fourteen rules over two years, and nothing underneath it is broken out. No rule shipped that week. The shape of the traffic changed, one of the fourteen is now doing more work per call than it used to, and the trace cannot say which one.

A dashboard of per-rule percentiles is rare across rule engines: none of the seven engines compared below documents one. It is rare for a structural reason: the same property that made extracting the rules from code worth doing.

Rules are data, so the profiler samples the wrong thing

Point a CPU profiler at the service under load and the frames it collects belong to the evaluator: a condition tree walk, an operator dispatch, a map lookup for a fact value. Those frames are identical for every rule in the ruleset. Which rule the evaluator was working on when the sample landed is a value in a field, not a name on the stack, so the flame graph shows you the engine's shape summed over the whole ruleset.

No better profiler closes that gap. A rule engine exists so policy stops being code, and code is the only unit a profiler knows how to attribute time to. The component that could attribute time to a rule has to sit inside the engine, where rule identity is a first-class value rather than an argument passed somewhere down the stack.

The obvious objection is that you could keep the rules in code and give each one a function of its own, so the profiler has a name to attribute time to. That only partly works. A small predicate called on every request is the first thing a JIT inlines, and an inlined frame is not on the stack when the sampler wakes up. Resolution is the second problem: a rule costing four microseconds is effectively invisible to a profiler sampling a hundred times a second, so what accumulates over hours is a share of CPU rather than the latency of any single call. A flame graph holds no percentiles at all, so a rule that is quick on most inputs and slow on a few shows up as a narrow frame either way. The biggest problem comes last: rules moved into data so they could change without a deploy, and moving them back into functions to satisfy a profiler gives that up. A threshold change becomes a PR again.

Averages make it worse. The rules worth finding are cheap on the common shape of input and expensive on an uncommon one, so their cost lives in the tail. A mean taken across a busy ruleset barely moves when that tail thickens, so nobody acts on it.

So teams reach for timers around the branches. In an if-else policy, that looks roughly like this:

long t0 = System.nanoTime();
boolean tierOk = checkPlanTier(ctx);
metrics.timer("policy.tier").record(System.nanoTime() - t0, NANOSECONDS);

long t1 = System.nanoTime();
boolean quotaOk = tierOk && checkMonthlyQuota(ctx);
metrics.timer("policy.quota").record(System.nanoTime() - t1, NANOSECONDS);

Two problems come with that code, and neither shows up in the numbers it produces. The metric name is a string somebody typed next to a branch, so the day the branch is renamed or moved, the series keeps reporting under its old name against different work. And the tierOk && short-circuit means policy.quota is timed only on calls that cleared the tier check, so the two series have different denominators.

What other engines actually give you

The comparison below rests on a survey of the public documentation of seven rule engines, plus source files for Drools and GoRules, asking what any of them reports at rule granularity. None of the seven was run for it.

Across those seven, none documents a rule-level latency percentile that the product computes and ranks rules by. Several come close, and the table shows where each one stops.

ProductWhat the documentation gives youWhat is missing
Decisions.comProfiler reports Total, Count, Min, Max, and Avg time per item, rules includedPercentiles. Data lives in memory and rolls over every fifteen minutes, so nothing accumulates
Drools (KIE Server)Prometheus histogram drl_match_fired_nanosecond, labeled with rule_namePercentiles, and condition timing. The timer covers the consequence (then), not the condition (when)
DecisionRules.ioexecutionTime on every audit log entry, charted over time (the unit it calls a rule is one whole decision table or tree)Summary statistics stop at minimum, maximum, and average. No percentile aggregation
GoRulesExecution time per node of a decision graph, plus a trace option (table rows report whether they matched, never how long)Per-rule time. Any distribution. Production observability is an OpenTelemetry export you assemble in your own APM
SAS Intelligent DecisioningExecution time per node of a decision, where a ruleset is one node, from a DEBUG performance log you switch onPer-rule instrumentation. The standing metrics are per module and per request, not per rule
OpenRulesEvery executed rule with the decision variables behind it, and Rule Solver's "Execution Profile" of solver search statisticsPer-rule duration. No column in the rule report is a time; the elapsed figure is one total for the decision, and the Execution Profile's is one total for the solve
AWS Verified Permissions / CedarNo timing. The authorizer hands back only the determining policies and any errorsThe engine does not time policy evaluation at all. Documented observability is one page about CloudTrail

Percentiles do turn up for four of these seven, and none of the four is per rule. The GoRules one is a mock-up dashboard on a marketing page, and the DecisionRules.io one is a load-test figure in the FAQ. Both are percentiles of how long a whole request took. The percentiles Kogito publishes for Drools are computed over request elapsed time and DMN output values. cedar-benchmarking is a tool the Cedar project runs to catch its own regressions, and it times policies a set at a time rather than one by one.

Drools, on KIE Server, ships the best raw data of the seven. (KIE Server is the Drools 7 server. From Drools 8 on, Kogito records a per-rule metric under the same name, but without histogram buckets unless the application turns them on in Micrometer.) KIE Server's histogram has buckets, so one histogram_quantile line of PromQL returns a per-rule p99. But the Grafana dashboard Kogito generates for a ruleset plots a one-minute average of the Kogito metric and never calls histogram_quantile on it, so the ten calls in a thousand that ran a hundred times longer than the rest are averaged away. And both timers wrap consequence execution, which leaves condition evaluation unmeasured, the half that grows as a ruleset accumulates clauses. Where the buckets exist, your own PromQL query can get the slow calls back, but no query can get condition time back.

Decisions.com will name a slow rule for you: the vendor's own walkthrough uses its Profiler to point at one. The Profiler reports no percentile, its data rolls over every fifteen minutes, and the vendor describes it as a tool for gathering information once an issue has already been identified. Champion Challenger has a comparison labeled performance, but that one weighs a rule in production against a changed copy of it on outcome, not on time.

Several of these engines time rules, and Drools emits numbers raw enough that you can compute whatever you like from them. Where the raw timings are exported at all, the per-rule percentile and the ranking are yours to build, in Grafana or Datadog or a spreadsheet. Someone has to own and maintain what gets built, and teams often leave that cost out when they compare running the engine themselves against letting someone else operate it.

The half the Drools timer never sees is why LexQ splits the condition stage (CONDITION) from the action stage (ACTION). The two do not share a sample size: in a sampled call, a rule's condition is timed whenever the rule is evaluated, and its actions only when they run, which leaves out calls where the rule matched but lost to another rule in its mutex group.

The table rests on the vendor pages and source files below. They are the sources for each row, so any row can be checked against the vendor's own words.

Three choices behind the per-rule numbers

LexQ has computed per-rule latency percentiles since 2026-07-14, on a screen it calls Rule Performance. Three design decisions in that build mattered more than the timing itself, because without any one of them, a rule-level number would mislead the person reading it.

The threshold lives inside the policy group

In LexQ, rules are filed under a policy group, called a group from here on. A rule is flagged when its p50 reaches ten times the median of the per-rule p50s in its own group. There is no absolute threshold, and leaving it out was deliberate. A fraud check and a shipping-cost calculation have no reason to share a normal range, so one absolute figure would have to be right for every domain at once, including the ones it was never chosen for. A comparison against siblings needs no such figure, and it needs no upkeep when servers or traffic change.

The comparison uses the median because a slow rule pulls a mean up toward itself. With five rules at 1, 1, 1, 1, and 40ms, the mean is 8.8ms, so ten times the mean is 88ms and the 40ms rule escapes, while ten times the median is 10ms and the rule is flagged. Because the flag compares p50s, a rule that is slow only on uncommon inputs is not flagged; it shows up in the p95 and p99 columns instead.

HIT and MISS never share a distribution

The first calls to reach a new version pay for a cache miss, and the extra time goes to one-time setup rather than to evaluating any rule. Merged into one distribution, those calls land in the slow tail an investigation is reading, and a side effect of deployment looks like a slow rule. Keeping HIT and MISS apart costs nothing and rules out that whole kind of wrong conclusion.

A sample too small is withheld rather than estimated

A p99 means something only if a few calls actually landed in the slow tail. LexQ draws that line at three calls, which is what n × (1 − q) ≥ 3 says, and it lands on n ≥ 6 for p50, n ≥ 60 for p95, and n ≥ 300 for p99. Below the bar the field is null. Flagging a rule as slow needs more data than showing its p50 or p95, so the flag has a gate of its own at n ≥ 100, and a group with fewer than three qualifying rules has nothing to compare against and says so with INSUFFICIENT_COHORT.

So a rule with n between 60 and 99 shows a p95 with no flag beside it, and there the missing flag only means not enough calls have accumulated to judge the rule. An estimate would have filled the blank, but a p99 assembled from four observations looks on screen exactly like a p99 assembled from four thousand.

The rule breakdown is built from one percent of calls, because timing every rule on every call would slow down the calls being measured. The group total is computed from every successful call. The total answers how much time the group takes, and the sample is spent on ranking rules against each other. Because only a hundredth of the traffic feeds the breakdown, the display gates above do real work.

Nothing in the time series charts is smoothed either. A gap in a rule's chart is a minute in which no sampled call evaluated that rule, and an interpolated point would be a number the engine never measured.

When you don't need this

Per-rule percentiles are worth their cost in one situation: a decision on a hot path, in a ruleset too large for anyone to keep track of what each rule costs. In the four cases below, they are not.

  • The decision is not on a hot path. A nightly batch or a back-office approval screen absorbs a few hundred milliseconds without anyone noticing. Total runtime answers the questions anyone will ask of it.
  • The ruleset is three or four rules. Hand-rolled timers drift from the logic they wrap, but drift takes edits and time to happen. Four branches that have not changed in a year cost less to instrument by hand than to move anywhere else.
  • The volume is too low to sample. A few hundred calls a day leaves a per-rule n in single digits under a one percent sample, and the display gates will hold most of the table at null. That is accurate for that traffic, but you cannot act on it.
  • The p99 problem is I/O. If facts arrive from another service, or the slow part is the query assembling them, every rule in the profile will look flat and identical, because the time is spent before any rule runs. Take the span breakdown first and open the rule profile when the evaluation span is the wide one.

Where to see it implemented

The implementation side of this (a hot-path quota gate, the rule that grew to eight OR branches over time, the profile that ranked it against its siblings, and the simulation run to prove that restructuring it changed no decisions) is written up separately as Sizing a Hot-Path Rule Rewrite with Per-Rule Profiling. The console screens and the actual numbers live there.

A decision that runs on every request deserves what production code gets, and every piece of production code on that path has a latency distribution attached to it as a matter of course. Rules were left out because attributing time to data requires the component that evaluates the data to record it, and that component is the engine. Check whether your engine records it before your p99 moves.

→ Find out what each rule costs per call. Start free at lexq.io

Move one rule out of your code.

Free to start, no credit card. Send facts, get back a result and the reasoning.

Start Free