proptest-rs / proptest

Hypothesis-like property testing for Rust
Apache License 2.0
1.69k stars 158 forks source link

Make VarBitSet saturated + FromIterator efficient #361

Closed sameer closed 1 year ago

sameer commented 1 year ago

I noticed that VarBitSet::saturated takes a significant amount of time when generating data with VecStrategy. There are two perf issues:

  1. not making use of the size hint in FromIterator leads to repeated grow calls
  2. saturated should use from_elem since we're setting all bits
sameer commented 1 year ago

I'm using Instruments on macOS to look at the CPU profile of a proptest and it's now optimized to memset 🚀

Before: Screenshot 2023-08-17 at 13 00 02

After:

Screenshot 2023-08-17 at 13 01 35

sameer commented 1 year ago

@matthew-russo are you able to approve the workflows / merge this?

matthew-russo commented 1 year ago

I didn't realize the workflows weren't running. just kicked that off. we normally try to get two maintainers eyes on things before merging -- i pinged the others yesterday to give a look.