Skip to main content

MAX_PATTERN_NFA_STATES

Constant MAX_PATTERN_NFA_STATES 

Source
const MAX_PATTERN_NFA_STATES: u64 = 100_000;
Expand description

Largest estimated NFA state count accepted for a whole pattern.

MAX_QUANTIFIER_BOUND alone does not bound the pattern: quantifiers nest, and nesting multiplies, so ((a{900}){900}) would expand to ~810000 copies of a while every individual bound is legal. This cap bounds the product. For scale: PERMUTE of the maximum MAX_PERMUTE_VARS variables estimates 8642 states (8.6% of the budget) and (a b c){1000} estimates 6000, so realistic patterns are far below it.

This is a memory bound, not a throughput one. The NFA is simulated from every candidate start for every row, so a pattern anywhere near this many states would build successfully and still be far too slow to be useful; the cap exists only to keep an absurd pattern from exhausting the compute node’s memory while the actor is being built.