Skip to content

Avoid repropagating unchanged IELR annotations - #872

Merged
ydah merged 1 commit into
masterfrom
perf/propagate-changed-ielr-annotations
Nov 12, 2026
Merged

ydah merged 1 commit into
masterfrom
perf/propagate-changed-ielr-annotations

Conversation

@ydah

@ydah ydah commented Nov 12, 2026

Copy link
Copy Markdown
Member

compute_inadequacy_annotations propagates a state's entire annotation list whenever the state is requeued, including annotations whose contribution matrices have not changed.

Keep a local snapshot of each propagated matrix and send only new or changed annotations to the predecessors. Take snapshots before propagation so updates made through cycles are picked up on the next visit. Preserve annotation order and propagate each changed matrix in full, including changes to unconditional contributions.

For Ruby's parse.y, this reduces the annotations processed by annotate_predecessor from 468,735 to 247,717 while keeping the final 31,677 annotations unchanged. Add regression tests for new and merged annotations, unconditional contributions, multiple predecessors, and self-loops.

Measured on Ruby 4.0.9, arm64 macOS, with YJIT disabled and 12 balanced, randomized baseline/candidate pairs per mode:

parse.y measurement Before After
CLI elapsed time 1.813s 1.660s
Warm total CPU time 1.663s 1.519s
Annotation propagation CPU time 0.752s 0.597s
Allocated objects 5,110,861 4,694,693

CLI elapsed time improves in all 12 pairs, with a paired mean reduction of 8.4% and a bootstrap 95% interval of 7.2–9.6%. Allocations decrease by 8.1%. Peak RSS and GC time show no clear improvement, and the two smaller grammars show no clear CLI elapsed-time improvement.

@ydah
ydah merged commit f0c480e into master Nov 12, 2026
66 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant