short-circuit opposite BDD literals and local tail contradictions #624

Open
RileyW wants to merge 1 commit from RileyW/Darner:pr/bdd-contradictions into Main
First-time contributor

Not yet run in-game on this Darner branch (unit tests and randomized BDD oracle checks run on this revision; shader translation optimization verified on RTX 3080 SM86 in a downstream fork).

What it changes

  • The problem on main: read from code and synthetic BDD reproduction (crates/darner-shader/src/structure.rs:326, Bools::meet_in and crates/darner-shader/src/resource.rs:625, Tracer::meet).

Two avoidable BDD search slowdowns / budget exhaustions occur during shader structuring and resource tracing:

  1. In Bools::meet_in, sorting and deduplicating work[at..] ran after checking *budget == 0 and did not detect adjacent complementary literals (b, false) and (b, true) (differing only in bit 0), causing unnecessary splits or conservative true answers when budget is exhausted.
  2. In Tracer::meet, passing [reach, c1, c2, ...] splits the large reach BDD first; when the local tail [c1, c2, ...] is already unsatisfiable on its own, expanding reach can exhaust MAX_MEET (65,536 splits) and conservatively return true.

This change:

  1. Checks adjacent opposite literals (work[i] ^ work[end - 1]) == 1 in Bools::meet_in before checking *budget == 0, returning false in O(1) with zero case splits (and updates the test reference oracle meet_anew to match).
  2. In Tracer::meet, when conditions.len() is at least 3, checks &conditions[1..] first and returns false immediately when the local tail is already unsatisfiable.
  3. Adds unit tests opposite_bdd_literals_short_circuit_even_when_budget_is_exhausted (structure.rs) and tracer_meet_short_circuits_local_tail_contradiction_under_large_reach_bdd (resource.rs, including a control proving raw meet_seen exhausts MAX_MEET on the wide reach BDD).

How it was tested

  • Tested revision: 525a349 (based on c8258f9)
  • Commands and results:
    • cargo test -p darner-shader --lib structure::tests --locked (17 passed, including 1,500-case randomized BDD oracle check across 11 budgets)
    • cargo test -p darner-shader --lib resource::tests --locked (61 passed)
    • cargo clippy --workspace --all-targets --locked -- -D warnings (0 warnings)
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (0 warnings)
    • cargo xtask policy and cargo xtask policy --staged (ok)
  • Changes a default: yes, for all hosts (purely sound BDD unsatisfiability short-circuits during shader translation).
  • A/B result: no in-game FPS A/B table yet (this reduces shader-translation BDD splits and avoids MAX_MEET false positives rather than runtime frame rendering; verified via unit test control where raw meet_seen exhausts 65,536 splits vs immediate false).
  • Gates run on that revision: both workspace clippy gates, cargo xtask policy, structure::tests, and resource::tests.
  • Gameplay: not yet re-run in-game on this Darner branch.
  • Hardware dependence: general (CPU shader translation).
  • Coverage gaps: no full-title shader corpus translation timing A/B collected on Darner yet.

Checklist

  • I ran this change in the game, or say below why it cannot be (CPU shader-translation unit tests run; in-game Darner run pending).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none found.
  • Replaces or overlaps: none found.
Not yet run in-game on this Darner branch (unit tests and randomized BDD oracle checks run on this revision; shader translation optimization verified on RTX 3080 SM86 in a downstream fork). ## What it changes - The problem on main: read from code and synthetic BDD reproduction (crates/darner-shader/src/structure.rs:326, Bools::meet_in and crates/darner-shader/src/resource.rs:625, Tracer::meet). Two avoidable BDD search slowdowns / budget exhaustions occur during shader structuring and resource tracing: 1. In Bools::meet_in, sorting and deduplicating work[at..] ran after checking *budget == 0 and did not detect adjacent complementary literals (b, false) and (b, true) (differing only in bit 0), causing unnecessary splits or conservative true answers when budget is exhausted. 2. In Tracer::meet, passing [reach, c1, c2, ...] splits the large reach BDD first; when the local tail [c1, c2, ...] is already unsatisfiable on its own, expanding reach can exhaust MAX_MEET (65,536 splits) and conservatively return true. This change: 1. Checks adjacent opposite literals (work[i] ^ work[end - 1]) == 1 in Bools::meet_in before checking *budget == 0, returning false in O(1) with zero case splits (and updates the test reference oracle meet_anew to match). 2. In Tracer::meet, when conditions.len() is at least 3, checks &conditions[1..] first and returns false immediately when the local tail is already unsatisfiable. 3. Adds unit tests opposite_bdd_literals_short_circuit_even_when_budget_is_exhausted (structure.rs) and tracer_meet_short_circuits_local_tail_contradiction_under_large_reach_bdd (resource.rs, including a control proving raw meet_seen exhausts MAX_MEET on the wide reach BDD). ## How it was tested - Tested revision: 525a349 (based on c8258f9) - Commands and results: - cargo test -p darner-shader --lib structure::tests --locked (17 passed, including 1,500-case randomized BDD oracle check across 11 budgets) - cargo test -p darner-shader --lib resource::tests --locked (61 passed) - cargo clippy --workspace --all-targets --locked -- -D warnings (0 warnings) - cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (0 warnings) - cargo xtask policy and cargo xtask policy --staged (ok) - Changes a default: yes, for all hosts (purely sound BDD unsatisfiability short-circuits during shader translation). - A/B result: no in-game FPS A/B table yet (this reduces shader-translation BDD splits and avoids MAX_MEET false positives rather than runtime frame rendering; verified via unit test control where raw meet_seen exhausts 65,536 splits vs immediate false). - Gates run on that revision: both workspace clippy gates, cargo xtask policy, structure::tests, and resource::tests. - Gameplay: not yet re-run in-game on this Darner branch. - Hardware dependence: general (CPU shader translation). - Coverage gaps: no full-title shader corpus translation timing A/B collected on Darner yet. ## Checklist - [ ] I ran this change in the game, or say below why it cannot be (CPU shader-translation unit tests run; in-game Darner run pending). - [x] This PR contains one change based on main. - [x] The diff follows docs/asset-policy.md. - [x] I recorded this PR dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none found. - Replaces or overlaps: none found.
TrustNo1 changed title from [pr-performance][shaders] short-circuit opposite BDD literals and local tail contradictions to short-circuit opposite BDD literals and local tail contradictions 2026-12-06 03:26:00 +00:00
Owner

Test needed — commit 525a3496; what to check:

  • The problem on main: read from code and synthetic BDD reproduction (crates/darner-shader/src/structure.rs:326, Bools::meet_in and crates/darner-shader/src/resource.rs:625, Tracer::meet).

Two avoidable BDD search slowdowns / budget exhaustions occur during shader structuring and resource tracing:

  1. In Bools::meet_in, sorting and deduplicating work[at..] ran after checking *budget == 0 and did not detect adjacent complementary literals (b, false) and (b, true) (differing only in bit 0), causing unnecessary splits or conservative true answers when budget is exhausted.
  2. In Tracer::meet, passing [reach, c1, c2, ...] splits the large reach BDD first; when the local tail [c1, c2, ...] is already unsatisfiable on its own, expanding reach can exhaust MAX_MEET (65,536 splits) and conservatively return true.

This change:

  1. Checks adjacent opposite literals (work[i] ^ work[end - 1]) == 1 in Bools::meet_in before checking *budget == 0, returning false in O(1) with zero case splits (and updates the test reference oracle meet_anew to match).
  2. In Tracer::meet, when conditions.len() is at least 3, checks &conditions[1..] first and returns false immediately when the local tail is already u

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `525a3496`; what to check: - The problem on main: read from code and synthetic BDD reproduction (crates/darner-shader/src/structure.rs:326, Bools::meet_in and crates/darner-shader/src/resource.rs:625, Tracer::meet). Two avoidable BDD search slowdowns / budget exhaustions occur during shader structuring and resource tracing: 1. In Bools::meet_in, sorting and deduplicating work[at..] ran after checking *budget == 0 and did not detect adjacent complementary literals (b, false) and (b, true) (differing only in bit 0), causing unnecessary splits or conservative true answers when budget is exhausted. 2. In Tracer::meet, passing [reach, c1, c2, ...] splits the large reach BDD first; when the local tail [c1, c2, ...] is already unsatisfiable on its own, expanding reach can exhaust MAX_MEET (65,536 splits) and conservatively return true. This change: 1. Checks adjacent opposite literals (work[i] ^ work[end - 1]) == 1 in Bools::meet_in before checking *budget == 0, returning false in O(1) with zero case splits (and updates the test reference oracle meet_anew to match). 2. In Tracer::meet, when conditions.len() is at least 3, checks &conditions[1..] first and returns false immediately when the local tail is already u Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/bdd-contradictions:RileyW-pr/bdd-contradictions'
git switch 'RileyW-pr/bdd-contradictions'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'Main'
git merge --no-ff 'RileyW-pr/bdd-contradictions'
git switch 'RileyW-pr/bdd-contradictions'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'RileyW-pr/bdd-contradictions'
git switch 'RileyW-pr/bdd-contradictions'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'RileyW-pr/bdd-contradictions'
git switch 'Main'
git merge --squash 'RileyW-pr/bdd-contradictions'
git switch 'Main'
git merge --ff-only 'RileyW-pr/bdd-contradictions'
git switch 'Main'
git merge 'RileyW-pr/bdd-contradictions'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!624
No description provided.