Skip to content

Optimize unit propagation with IncompatibilityIndex and binary clause fast-skipping - #4882

Draft
sigurdm wants to merge 2 commits into
dart-lang:mainfrom
sigurdm:optimize-2wl-propagation
Draft

Optimize unit propagation with IncompatibilityIndex and binary clause fast-skipping#4882
sigurdm wants to merge 2 commits into
dart-lang:mainfrom
sigurdm:optimize-2wl-propagation

Conversation

@sigurdm

@sigurdm sigurdm commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Optimizes PubGrub unit propagation in VersionSolver by introducing a specialized IncompatibilityIndex and binary clause fast-skipping:

  • IncompatibilityIndex: Encapsulates incompatibility indexing and candidate iteration out of VersionSolver, reducing VersionSolver._propagate to a clean ~20-line loop.
  • Binary Clause Fast-Skipping: In version solving, most incompatibilities are binary dependencies (e.g. {foo ^1.0.0, not bar ^2.0.0}). During propagation, candidate binary clauses where neither term is satisfied by the partial solution are skipped immediately, avoiding redundant _propagateIncompatibility evaluations while preserving exact PubGrub resolution semantics and reverse-chronological ordering.
  • Documentation: Updated doc/solver.md with an explanation of binary clause specialization.
  • Tests: Added comprehensive unit tests in test/incompatibility_index_test.dart.

… fast-skipping

- Extract IncompatibilityIndex to encapsulate clause indexing and candidate iteration.
- Fast-skip binary clauses where neither term is satisfied by the partial solution.
- Update doc/solver.md to describe binary clause specialization.
- Add unit tests for IncompatibilityIndex.
… without redundant checks

- Provide IncompatibilityIndex.forPackage() returning reverse-chronological iterable.
- Eliminate redundant relation checks and per-package closure allocations.
- Revert binary clause specialization text in doc/solver.md.
- Update tests for IncompatibilityIndex.
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