Ray's Knowledge Base
Unlock

A plugin pruning judge has three forms: rule builder, template, plain may_match

DecisionVerified 5 Oct 2026Holds project: dftracer-utils
Decision. The context, the choice, why, and the options that were turned down.

Context#

A dftracer-utils plugin extension needs a pruning judge that can run at query time everywhere.

Decision#

  1. Rule builder: static Rules rules() returns rule(Op::GT, mixed || max > value()), built from field(&T::max) and value() objects.
  2. A generic function template that works on real numbers or on those same symbolic expression types.
  3. An ordinary may_match, plain C++, for judges with data-dependent loops, own data structures or library calls.

Forms 1 and 2 are "lowered": the host runs them everywhere, including MPI, with no worker and no plugin loaded. Form 3 runs in the worker, or in process on Dask and MPI. The author picks one per extension. If both a lowered and a plain form are given, the host uses the lowered form, and the plugin-load self-test checks on random states and values that both keep the same chunks.

The template is almost free once the builder's expression types exist. It wins when the same logic must run at build time and at query time (for example normalizing file names in update and again on the filter literal in the judge): one definition cannot drift apart, while a builder-only rule is written twice, only a test catches a mismatch, and a drift loses rows. Its costs: no if on data, no early return, every field read is s.get(&T::max) instead of s.max (C++20 cannot build a symbolic struct with the same member names), and long compiler errors.

Why#

Lowered forms run without a plugin load; the plain form covers logic that cannot be expressed symbolically.

Rejected options#

  • Requiring authors to write both a lowered and a plain judge.

Also found by searching

  • three forms of a plugin pruning judge rule builder template may_match
  • lowered judge runs on MPI without plugin loaded
  • why offer a generic function template for the plugin judge
  • plugin judge drifts from update normalization and loses rows