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
{{ message }}
Repository navigation
Policy speed: a loop's values are read one by one since 1.5.3 (a 1,000-file loop 3.4 ms to 31 ms) #575
1.5.3 reads each value a loop variable can hold as its own reading of the loop body, so a deny that only one value makes isn't missed. That made long loops slower to decide. Everyday commands didn't change much. Best of 3 on a laptop (Apple M-series, dev.yaml, both engines alike):
command
1.5.2
1.5.3
for f in a0 a1 ... ; do echo $f; ls $f; cat $f; done (60 KiB)
17 ms
300 ms
ls x[a-p] x[a-p] ... (60 KiB)
26 ms
84 ms
for f in src/m_0.py ... src/m_999.py; do black "$f" && git add "$f"; done
The parse budget still bounds every line, so this isn't a hang. But a 1,000-file loop is a real command, and 9x is more than it should cost. CI runners take 2-4x as long.
The constraint: the fix must not read fewer values. Each value still gets a reading, or the one that makes a deny is missed (for d in build /; do rm -rf "$d"; done). Faster ways to get the same decisions:
Group values that read alike. Values made only of characters no rule treats specially (src/m_12.py, a7) could share one reading, if every rule's match on them is the same. Prove that per rule, or keep separate readings for values that differ in anything a rule reads.
Read the body once and substitute values into its parsed words, instead of re-parsing the body text for each value.
Profile first (python -m cProfile on the 60 KiB loop) to see where the 300 ms goes.
Task:
Profile the four commands above on main and post the top 10 functions here.
Make the change. The verdicts must not change: run tests/test_policy2.py and tests/test_signer_policy.py in full, and eval/e21_policy_robustness.py, and compare the dev corpus verdicts before and after (eval/e17_policy_corpus.py).
A test that times the 1,000-file loop, next to test_literal_values_and_bracket_patterns_stay_within_the_parse_budget.
Done when: the 1,000-file loop decides in under 10 ms and the 60 KiB loop in under 100 ms on a laptop, with no verdict changed on any corpus. Give the before and after numbers in the PR.
It isn't only loops. E21's CI gate (each pack's p99 at most 1 ms on the runner) now sits at the edge: on #577's run, default/regex p99 was 1001 us (failed), and the others 707-864 us, with p50 about 300 us. An ordinary command went from 0.1 ms to 0.2 ms on a laptop in 1.5.3 (the second reading where an expansion may be empty), so every decision costs about twice what it did. Scope: profile the E21 corpus too, not only the loop cases, and bring CI's p99 well under 1 ms with no verdict changed.
Reopened: #580 made loops and second readings faster with the same verdicts (60 KiB loop 308 → 106 ms, 1,000-file loop 32 → 22.5 ms, E21 p99 313 → 231 µs), but the targets here aren't reached yet (under 10 ms and 100 ms). The next step is grouping loop values that read alike, which needs a per-rule proof that their matches are identical.
Activity
LoopGlitch26 commentedon Nov 3, 2026
It isn't only loops. E21's CI gate (each pack's p99 at most 1 ms on the runner) now sits at the edge: on #577's run,
default/regexp99 was 1001 us (failed), and the others 707-864 us, with p50 about 300 us. An ordinary command went from 0.1 ms to 0.2 ms on a laptop in 1.5.3 (the second reading where an expansion may be empty), so every decision costs about twice what it did. Scope: profile the E21 corpus too, not only the loop cases, and bring CI's p99 well under 1 ms with no verdict changed.policy: decide loops and second readings faster, with the same verdic…
LoopGlitch26 commentedon Nov 4, 2026
Reopened: #580 made loops and second readings faster with the same verdicts (60 KiB loop 308 → 106 ms, 1,000-file loop 32 → 22.5 ms, E21 p99 313 → 231 µs), but the targets here aren't reached yet (under 10 ms and 100 ms). The next step is grouping loop values that read alike, which needs a per-rule proof that their matches are identical.
LoopGlitch26 commentedon Nov 9, 2026
Refreshed as #683 with current file paths.