Skip to content

Commit 65e6328

Browse files
NateD-MSFTCopilot
andcommitted
IrqlFloatStateMismatch: pragma[inline_late] on irqlChangesBetween
The `irqlChangesBetween/2` predicate is the hottest single predicate in the IFSM query at HEAD (~109 s of CPU and 3.43 M result tuples in the 18-query suite measurement on the WDS sample database, accounting for roughly a quarter of the IFSM query's total cost). Without a planner hint, the predicate is materialized as a standalone relation over every `(FunctionCall, FunctionCall)` pair in the codebase that satisfies its constraints, and only then intersected with the ~25-row dataflow result set produced by `FloatStateFlow::flow`. With `pragma[inline_late]` plus the matching `bindingset[saveCall, restoreCall]`, the body is specialized at the single call site after the dataflow result has bound both arguments, so the predicate body is evaluated only on the small set of dataflow-derived pairs. Validation on the WDS sample database (single-query run, cold cache): - SARIF result count for cpp/drivers/irql-float-state-mismatch: 0 (matches the HEAD baseline of 0; correctness preserved) - `irqlChangesBetween` no longer appears as a discrete predicate in the evaluator log (it has been fully inlined into its call site) - New top single-query predicate: 28.9 s, vs 109 s for the standalone `irqlChangesBetween` in the baseline suite measurement This is a planner-hint change only. The predicate body is byte-for-byte unchanged, so the set of `(saveCall, restoreCall)` pairs the predicate admits (and therefore the set of `select` rows the query produces) is unchanged on every database. The `bindingset` is honest: the only caller (line 215) binds both arguments via the `FloatStateFlow::flow` result and the `asIndirectExpr` constraints in the same `where` clause. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ad1379a commit 65e6328

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/drivers/general/queries/IrqlFloatStateMismatch/IrqlFloatStateMismatch.ql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,23 @@ private int anchorLineForCall(Function f, FunctionCall fc) {
157157
* still be filtered out by the upstream IRQL filter even when this
158158
* predicate fires; recovering those will require improvements to
159159
* the IRQL analysis library itself.
160+
*
161+
* Performance note: `pragma[inline_late]` lets the planner specialize
162+
* this predicate at its call site after the dataflow result has bound
163+
* `saveCall` and `restoreCall`. Without it, the body would otherwise
164+
* be materialized over every (saveCall, restoreCall) pair in the
165+
* codebase that satisfies the constraints (millions of tuples on
166+
* large drivers), only to be intersected with a much smaller dataflow
167+
* result set afterwards. With it, the body is evaluated only for the
168+
* dataflow-derived pairs, turning a codebase-wide enumeration into a
169+
* per-pair check. The accompanying `bindingset` records the calling
170+
* convention required by `inline_late` (both arguments bound at the
171+
* call site, which is satisfied by the `from` clause below).
172+
* Semantics are unchanged — both annotations are planner hints, not
173+
* logical changes.
160174
*/
175+
bindingset[saveCall, restoreCall]
176+
pragma[inline_late]
161177
predicate irqlChangesBetween(FunctionCall saveCall, FunctionCall restoreCall) {
162178
// Branch 1: source-line bracketing in a function `f` that anchors
163179
// both calls (directly enclosing or one-level wrapper / common caller).

0 commit comments

Comments
 (0)