Skip to content

Cache clause differences when simplifying large marker DNFs - #22606

Merged
charliermarsh merged 1 commit into
charlie/compact-conflict-markersfrom
charlie/marker-dnf-candidates
Oct 16, 2026
Merged

charliermarsh merged 1 commit into
charlie/compact-conflict-markersfrom
charlie/marker-dnf-candidates

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Summary

When simplifying a DNF, we can compare each clause with the others for every term we consider removing. For markers with many clauses that reuse the same terms, as with conflicting extras, we can end up computing the same differences over and over.

This PR caches the relevant differences for each clause and reuses them as we check its terms. We skip candidates that cannot justify a removal, and update the cached differences when a term is removed so later comparisons see the updated clause.

We use this path for large DNFs with relatively few distinct terms. Smaller or sparser expressions continue to use the comparisons introduced in #22604. The DNF still needs to be created, and the number of clause comparisons can still be quadratic.

CodSpeed comparison against #22604 measures the 25 marker cases in both walltime and simulation. CodSpeed flags a simulation environment difference; the wall-time results have no runner mismatch.

@codspeed

codspeed Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 2 benchmarks

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 5 improved benchmarks
❌ 2 regressed benchmarks
✅ 112 untouched benchmarks
⏩ 54 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation imbibe_marker_no_conflicts[0] 343 ns 398.5 ns -13.94%
❌ ⚠️ Simulation discover_workspace_from_all_members 134.5 ms 142.9 ms -5.88%
⚡ WallTime imbibe_and_format_marker_conflict_dependent[32] 15.8 ms 5.8 ms ×2.8
⚡ WallTime marker_to_dnf_conflicting_extras[32] 4 ms 1.9 ms ×2.1
⚡ Simulation imbibe_and_format_marker_conflict_dependent[32] 297.2 ms 150.6 ms +97.35%
⚡ Simulation marker_to_dnf_conflicting_extras[32] 73.6 ms 48.2 ms +52.64%
⚡ ⚠️ Simulation discover_workspace_from_all_members_with_excludes 163.9 ms 155.5 ms +5.39%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing charlie/marker-dnf-candidates (6e34068) with charlie/marker-dnf-bitsets (74ec208)

Open in CodSpeed

Footnotes

  1. 54 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@charliermarsh
charliermarsh removed this pull request from stack #22607 October 15, 2026 20:26
@charliermarsh
charliermarsh force-pushed the charlie/marker-dnf-candidates branch from 61248ae to c5d490e Compare October 15, 2026 20:26
@charliermarsh
charliermarsh changed the base branch from charlie/marker-dnf-unsimplified to charlie/marker-dnf-bitsets October 15, 2026 20:27
@charliermarsh
charliermarsh removed this pull request from stack #22609 October 15, 2026 20:31
@charliermarsh
charliermarsh force-pushed the charlie/marker-dnf-candidates branch from c5d490e to fb694a9 Compare October 15, 2026 20:31
@charliermarsh
charliermarsh force-pushed the charlie/marker-dnf-candidates branch from fb694a9 to 9374f28 Compare October 15, 2026 20:40
@charliermarsh
charliermarsh force-pushed the charlie/marker-dnf-candidates branch from 9374f28 to c382f59 Compare October 15, 2026 20:43
@charliermarsh
charliermarsh removed this pull request from stack #22611 October 15, 2026 20:58
Large marker DNFs often reuse a small set of terms across many clauses. The indexed simplifier recomputes the difference between two clauses for each term it considers removing. Compute viable differences once per clause and reuse them across those term checks.

Count missing terms first to discard candidates that cannot justify a removal, then update the cached differences after each removal so later checks use the surviving terms. Enable this path only when enough clauses reuse relatively few terms; smaller and sparser DNFs retain direct comparisons. Differential tests check that both paths produce the same ordered output as the linear simplifier.
@charliermarsh
charliermarsh force-pushed the charlie/marker-dnf-candidates branch from 6e34068 to 86706d3 Compare October 16, 2026 15:10
Base automatically changed from charlie/marker-dnf-bitsets to charlie/compact-conflict-markers October 16, 2026 15:10
@charliermarsh
charliermarsh merged commit 86706d3 into main Oct 16, 2026
@charliermarsh
charliermarsh deleted the charlie/marker-dnf-candidates branch October 16, 2026 15:10
@charliermarsh
charliermarsh restored the charlie/marker-dnf-candidates branch October 16, 2026 15:11

This branch was previously deployed

1 inactive deployment
automations — 86706d3a Deployed Oct 16, 2026 by charliermarsh via review / security review #51353
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.

2 participants