You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Distinguish between "light" and "heavy" flambda2 invariants (#3205)
* Distinguish between "light" and "heavy" flambda2 invariants
Light invariants can be checked in the CI, while heavy invariants are
intended for local debugging. More precisely:
- Light invariants must be fast to check and have low complexity. A guideline
is that it is acceptable to call `find` or `mem` functions, but they should
not use any kind of iterations iterations (`iter`, `fold`, `exists`, etc.).
It must be viable to enable light invariants in regular user workflows
without significantly impacting the performance of the compiler.
Light invariants are enabled by the pre-existing `-dflambda-invariants`
compiler flag, which is also enabled with `--enable-flambda-invariants`
configure flag.
To determine in code whether light invariants should be checked, call the
function `Flambda_features.check_light_invariants ()`.
Light invariants are checked on CI jobs, which should prevent drifts between
the expressed invariants and the actual invariants.
- Heavy invariants are allowed to be (almost) unbounded in complexity. They
are not intended to be enabled during regular workflows, but rather to be
used to help identify the source of a bug once it has been identified that
one exists. It is fine if enabling heavy invariants drastically slow down
the compiler on some inputs.
Heavy invariants are enabled by a new `-dflambda-heavy-invariants`
compiler flag. This flag implies `-dflambda-invariants`, so light invariants
are always checked when heavy invariants are checked.
To determine in code whether heavy invariants should be checked, call the
function `Flambda_features.check_invariants ()`.
Heavy invariants are *not* checked on CI jobs at the moment. They currently
include invariants that are known to be broken and should be investigated
before being moved to the light invariants.
The name of the compiler flags (invariants/heavy invariants) and feature checks
(light invariants/invariants) is chosen to reflect that users should usually
enable light checks only, but calling `check_light_invariants ()` is a reminder
to make sure the invariant does not do any expensive computation.
A few invariants related to the typing env and aliases that currently hold and
perform no iterations are moved to the set of light invariants. The goal is
that invariants are slowly moved from the heavy set to the light set over time
when it seems useful.
* Support OCAMLPARAM=flambda-invariants=heavy
0 commit comments