Skip to content

perf: use native words in IndexedSet and hoist forbid lookups - #288

Merged
baszalmstra merged 1 commit into
prefix-dev:mainfrom
baszalmstra:perf/resolvo-encoding-optimizations
Aug 26, 2026
Merged

perf: use native words in IndexedSet and hoist forbid lookups#288
baszalmstra merged 1 commit into
prefix-dev:mainfrom
baszalmstra:perf/resolvo-encoding-optimizations

Conversation

@baszalmstra

@baszalmstra baszalmstra commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

IndexedSet is backed by a growable Vec<usize> bitset, using the native machine word size while preserving the existing set API.

The encoder also resolved a solvable's package name and looked up its pending forbid-clause bucket once per candidate. Candidates in one version-set candidate list share a package name, so this now happens once per list. The allow_multiple check and forbid bookkeeping move out of the inner loop as well.

What changed

  • Store IndexedSet bits in native machine words and remove the unused bitvec dependency.
  • Resolve forbid-target names once per candidate list instead of once per candidate.
  • Assert in debug builds that every candidate list has one package name.
  • Add regression coverage for word boundaries, sparse and large indices, duplicate insertion, unions, empty candidate lists, locks, exclusions, and allow_multiple.

Benchmarks

Benchmarked with a 1,134,320-record conda-forge snapshot using 351 fixed-seed, precomputed workloads. Both builds used the same requirement sequence, a 60-second per-solve timeout, and produced identical outcome categories: 129 solved and 222 unsatisfiable.

metric main this PR
total solve time 130.25 s 106.07 s
mean 371.1 ms 302.2 ms
median 257.7 ms 202.1 ms
p95 909.4 ms 729.4 ms
max 3.78 s 3.43 s

This reduces total solve time by 24.18 s (18.6%), or 1.23x throughput.

339 of 351 problems are faster. The largest improvement is 358 ms; the largest regression is 25 ms.

Solve duration histogram

Per-problem duration difference

Testing

  • pixi run -e test-rust cargo fmt --check
  • pixi run -e test-rust cargo test --all-features

@baszalmstra
baszalmstra force-pushed the perf/resolvo-encoding-optimizations branch from 224ed15 to d87921e Compare August 26, 2026 08:19
Store IndexedSet bits in native machine words and resolve a candidate list's name once when registering forbid targets.

Add the candidate-list name invariant in debug builds and keep IndexedSet's coverage next to its implementation.
@baszalmstra
baszalmstra force-pushed the perf/resolvo-encoding-optimizations branch from d87921e to 8cd80b3 Compare August 26, 2026 08:19
@baszalmstra baszalmstra changed the title perf: use u64 words in IndexedSet and hoist forbid lookups perf: use native words in IndexedSet and hoist forbid lookups Aug 26, 2026
@baszalmstra
baszalmstra merged commit 902eafe into prefix-dev:main Aug 26, 2026
9 checks passed
@octo-sts octo-sts Bot mentioned this pull request Aug 24, 2026
@dralley

dralley commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@baszalmstra What is the impact on memory usage?

@baszalmstra

Copy link
Copy Markdown
Contributor Author

I didnt measure! But I expect very little since this is only used with dense layouts.

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