Skip to content

Count conflicts by lookahead token - #878

Merged
ydah merged 1 commit into
masterfrom
fix/count-conflicting-lookaheads
Nov 20, 2026
Merged

ydah merged 1 commit into
masterfrom
fix/count-conflicting-lookaheads

Conversation

@ydah

@ydah ydah commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Conflict totals currently count conflict objects, although one object can cover several lookahead tokens and several objects can describe the same token. This can overcount S/R conflicts and either overcount or undercount R/R conflicts.

Count S/R conflicts once per state and lookahead token, and R/R conflicts once for each reduction after the first on that token, matching Bison 3.8.2's counting convention.

Conflicts in one state Before After
One shift and two reductions on one token 2 S/R 1 S/R
Two reductions sharing two tokens 1 R/R 2 R/R
Three reductions sharing one token 3 R/R 2 R/R

Use the same per-state counts for warnings, report summaries, and %expect diagnostics. Keep individual conflict pairs for detailed reports and counterexamples. Remove memoized totals so queries made before computation or between LALR and IELR do not retain stale counts.

Measured on Ruby 4.0.9, arm64 macOS, with YJIT disabled and 12 balanced, randomized baseline/candidate pairs per mode. Before is master at 970b304; After is 08aa82a. Values are means. CLI measurements include startup and C output generation; warm measurements follow one warm-up run and GC.start.

parse.y measurement Before After
CLI elapsed time 1.653s 1.659s
Warm total CPU time 1.483s 1.485s
Warm allocated objects 4,707,007 4,704,113
Warm GC count 16.92 17.00
Warm GC time 0.165s 0.165s
CLI peak RSS 145.0 MiB 145.3 MiB

The paired mean CLI elapsed-time change is +0.37%, with a bootstrap 95% interval of −0.70% to +1.30%. There is no clear change in parse.y time, GC activity, or peak RSS. The smaller IELR fixture shows a 0.086 ms increase in warm CPU time (+1.5%), but no clear CLI time change. This is a diagnostic correctness fix; no speedup is claimed.

@ydah
ydah merged commit 22de9d9 into master Nov 20, 2026
45 checks passed
@ydah
ydah deleted the fix/count-conflicting-lookaheads branch November 20, 2026 10:35
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