Repository navigation
Share DNF simplification across clause representations - #22642
charliermarsh wants to merge 4 commits into
Conversation
Merging this PR will regress 4 benchmarks
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | imbibe_marker_no_conflicts[0] |
287.4 ns | 398.5 ns | -27.88% |
| ❌ | WallTime | marker_to_dnf_conflicting_extras[4] |
2.3 µs | 2.5 µs | -6.4% |
| ❌ | WallTime | marker_to_dnf_platform_specific_python_versions |
910 ns | 961 ns | -5.31% |
| ❌ | WallTime | imbibe_and_format_marker_environment_only[4] |
3 µs | 3.2 µs | -5.17% |
| ⚡ | Simulation | imbibe_and_format_marker_conflict_dependent[16] |
11 ms | 6.2 ms | +77.55% |
| ⚡ | Simulation | marker_to_dnf_conflicting_extras[16] |
3.2 ms | 2 ms | +61.06% |
| ⚡ | Simulation | imbibe_and_format_marker_environment_only[16] |
3.4 ms | 2.2 ms | +55.93% |
| ⚡ | WallTime | imbibe_and_format_marker_conflict_dependent[16] |
592.2 µs | 452.9 µs | +30.78% |
| ⚡ | WallTime | imbibe_and_format_marker_environment_only[16] |
185.9 µs | 152.3 µs | +22.05% |
| ⚡ |
Simulation | discover_workspace_from_all_members |
153.8 ms | 140.8 ms | +9.25% |
| ⚡ | Simulation | marker_to_dnf_sparse_clauses[128] |
5.8 ms | 5.4 ms | +6.02% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing charlie/shared-dnf-simplifier (21f4b07) with charlie/marker-dnf-candidates (cceb622)
Footnotes
-
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. ↩
86706d3 to
cceb622
Compare
b8c44d3 to
21f4b07
Compare
|
Superseded by #22651. |
We extract marker DNF directly from the decision diagram with a memoized ISOP algorithm, instead of enumerating paths and simplifying the resulting clauses. This avoids expensive clause comparisons for markers with many conflicting extras and replaces #22640, #22641, and #22642. Marker strings can change, but remain logically equivalent. We also fix Python-version complexification to preserve the variable ordering required by the traversal. Warm medians in microseconds, comparing #22642 (`21f4b07`) with this PR (`f9df0b8`): | Operation | #22642 | This PR | Speedup | | ---------------------------------------- | ------: | ------: | ------: | | Two-clause DNF | 0.606 | 0.433 | 1.4× | | Mixed Python/platform DNF | 1.125 | 0.658 | 1.7× | | Sparse DNF, 512 clauses | 8,010.3 | 65.0 | 123× | | Conflict DNF, 32 extras | 2,959.6 | 46.0 | 64× | | Conflict-dependent formatting, 32 extras | 8,690.4 | 109.9 | 79× | Measured on a pinned AMD EPYC Linux core with Rust 1.99.0-dev / Ohm, using 48 samples across three cohorts. Input construction is untimed. These are warm-interner microbenchmarks, not end-to-end resolution timings. The first mixed conversion in a fresh process is slightly slower: 16.6 µs → 20.3 µs.
Summary
We currently have separate DNF simplification passes for direct comparisons, indexed comparisons, and cached clause differences. Each pass has to remove terms and clauses in the same order, since one removal can affect the next.
This PR shares the ordered removal pass through a private trait for clause comparisons. Small markers still compare expressions directly, without interning their terms. Larger markers use the existing bit sets and cached differences. Each representation keeps its own removal state, and the caching choice stays inside the indexed implementation. Redundant clauses use indexed Boolean flags, with inline storage for small DNFs, so membership checks remain constant-time. The original linear simplifier is compiled only for tests, where it checks the exact ordered output of both representations.
We retain the existing indexing thresholds, repeated-term fallback, and index memory limit. DNF creation and quadratic clause comparisons remain.
Native Criterion measurements on a quiet Linux devbox compared the original patch-equivalent parent (
6e34068) with the original head (f25b35f). Both used uv's allocator and the same Ohm 1.98.1 compiler and profiling profile. Negative changes mean less time:to_dnf, two clausesto_dnf, mixed clausesto_dnf, 32 conflicting extrasto_dnf, 512 sparse clausesimbibeand format, conflict-dependent marker [4]imbibeand format, conflict-dependent marker [32]Each value is the median of three process estimates, with 20 Criterion samples per run and versions interleaved on the same pinned core. Diagrams are built before timing. These short runs do not reliably distinguish changes of a few percent, and operation measurements do not establish a lock or export speedup.