Skip to content

select_quadrature costs 27-32 s at target_degree=31 on EVERY geometry, including ones that cannot select the expensive rule #372

Description

@deOliveira-R

Filed from Q6 finding R-11. Benign today, and a blocker the moment select_quadrature gains a production consumer ([M] it has none).

[M] 2026-08-14, wall-clock per call:

geometry deg 21 deg 31
slab 0.787 s 26.985 s
sphere 32.419 s
cylinder 29.040 s
cartesian2d 28.987 s

Below degree 21 every geometry is under 0.8 s.

Cause

The V stage runs before the domain stage, so every geometry pays to construct every rule whose inverter answers — including rules it can never select. A slab pays ~27 s to build a level-symmetric rule that stage 0 then rejects on domain, because a μ-marginal geometry cannot use an S² rule.

The ordering is not casually reversible and registry.py argues why: a rule's invariance group and its exactness claim are both properties of an instantiated rule, and the nodes need parameters that only the V constraint fixes. Stage 0 compares measure.support, which also needs the measure.

The expensive part is the level-symmetric family: _ls_sn_invert builds candidate rules to discover both the positivity frontier and the realized degree (deliberately — "ask the family, never tabulate", and that ruling was vindicated when #337 moved the frontier with zero edits to the inverter).

Possible directions, none obviously right

  1. Cheap pre-filter on the spec. Something parameter-free and always-true that excludes a family from a geometry before construction — but the retired invariance_group field is the cautionary tale: a rule's symmetry is parameter-dependent and the parameter-free version had to lie. Whether a domain pre-filter has the same problem is the question: [M] a family's support looks parameter-independent (GL is always [-1,1], Lebedev always S^2), but that is an observation about four rules, not a theorem.
  2. Cache the construction. level_symmetric_sn is called repeatedly with the same orders across a session; functools.cache on the rule constructors would collapse the repeat cost. Cheapest option, does not address a cold first call.
  3. Accept it. The honest statement already in the tree (_ls_sn_invert): "selection is not a hot path, so the honest check is affordable." That is true while there are no production consumers.

⚠ Do not resolve this by re-tabulating the frontier or the degree — both were tabulated, both went stale, and b02dd536 / 37f3f880 removed the last of those copies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    module:datadata/ cross-section infrastructuretype:improvementEnhancement to existing functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions