Performance
Iris limits work that can grow without corresponding input. Two work budgets count operations defined by the Specification, independently of elapsed time and of how an implementation allocates memory. Each applies to a whole read or catalog operation.
The two budgets
Section titled “The two budgets”Let N be the entire original input’s byte length, including comments and bytes
after a stop or selected instance. Each operation starts with these limits:
| Work | Limit | Examples of charged work |
|---|---|---|
| Idle | 1048576 | Counted repeat iterations that read no input; empty array rows |
| Expression | 1048576 + 16 × N | Aggregate leaves, array and record selections, comprehension visits, lifted-check rows |
Reaching a limit exactly is allowed; exceeding either one reports
E-BUDGET. The counters do not reset when
a repeat ends, input advances or an instance is skipped. A catalog shares them
across all its instances. Reader-spec bytes and parameter strings do not add to
N. iris check executes neither budget.
The Specification defines counters and input length and expression charges.
Empty rows consume idle work
Section titled “Empty rows consume idle work”A zero-width array can still require many outer rows. This reader uses a parameter to choose how many empty rows to construct:
param rows = 3empty[rows][0]: intIts input file is empty; no tokens are needed:
Empty file.
iris read site/examples/guides/empty-rows.iris site/examples/guides/empty.txt --dznrows = 3;
empty = array2d(1..3, 1..0, []);
empty[rows][0] adds rows idle units before constructing the empty structure.
Increasing only the parameter exceeds the allowance, even with zero input:
iris read site/examples/guides/empty-rows.iris site/examples/guides/empty.txt --dzn --param rows=1048577site/examples/guides/empty.txt:1:1: too many repetitions or empty rows without reading input
1 |
| ^
while reading: empty
spec: site/examples/guides/empty-rows.iris:2
The failure happens at the array declaration. It is a work limit, not a memory allocation failure and not a timeout. The exact empty-array charges are in idle work, and diagnostic locations are in exhaustion.
Keep work proportional to input
Section titled “Keep work proportional to input”Use counted repeats when the input supplies a count, and token or EOF repeats when the input supplies a terminator. An indefinite repeat or instance body that consumes no input reports E-NO-PROGRESS, separately from the idle budget.
Use distinct to test uniqueness rather than comparing every pair in nested
comprehensions. Sum a collection once with let when several later checks need
the same total. Keep record checks local when their condition concerns one
record. The job shop reader
shows both a per-job distinct and a single total-duration calculation.
Short circuit can avoid evaluating later expressions. It does not remove the row-selection charges that a lifted check incurs before evaluating its condition. See lifted-check traversal. If a read exhausts a budget, reduce repeated traversal or idle structure creation. Padding the input to raise the limit leaves the underlying work in place.