[experiment] - use DenseBitSetStorage to implement SparseBitMatrix without per-row allocation - #161584
[experiment] - use DenseBitSetStorage to implement SparseBitMatrix without per-row allocation#161584panstromek wants to merge 8 commits into
Conversation
This doesn't change any behavior and still keeps the default storage to Vec<Word>.
This doesn't make much sense actually but based benchmarks, it has some impact, as SparseBitMatrix data has usually very few columns
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[experiment] - use DenseBitSetStorage to implement SparseBitSet without per-row allocation
|
The job Click to see the possible cause of the failure (guessed by this bot) |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (2d9a55d): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.2%, secondary 5.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 469.531s -> 484.971s (3.29%) |
|
A related idea I had at one point is that if we declare these two concrete types: pub(crate) struct RawBitSetRef<'a> {
domain_size: usize,
words: &'a [Word],
}
pub(crate) struct RawBitSetMut<'a> {
domain_size: usize,
words: &'a mut [Word],
}Then the vast majority of bitset operations can be defined by projecting the underlying storage to a raw bitset and calling an underlying implementation on the raw bitset. |
|
I did try that with the storage abstraction (i.e. I tried this on a few hot bitsets, but so far haven't found a one where it would help. This makes me think that I probably misunderstand where the BitSet costs are coming from a bit.
|
|
I removed the SparseBitMatrix usage in LiveLoans and now it's only used in region inference where this can potentially help more. Let's try again. [edit] well... maybe I misremembered this but let's try anyway :D @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
[experiment] - use DenseBitSetStorage to implement SparseBitMatrix without per-row allocation
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (7b48929): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.4%, secondary 2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 477.191s -> 477.8s (0.13%) |
|
☔ The latest upstream changes (presumably #161957) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
This is an experiment for the DenseBitSetStorage abstraction.
Based on cachegrind benchmarks, this has some impact, as SparseBitMatrix data usually has very few columns, so the empty row in the original implementation actually takes more memory than the non-empty row would allocate. Storing the data inline should take less memory.
This implementation doesn't make much sense though, because there's BitMatrix that's cleaner and works in pretty similar way.
If we proceed with this, it might make more sense to implement it differently (probably as growable BitMatrix).