Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize BddVariableSet::new, 2x speedup #62

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

zao111222333
Copy link
Contributor

Hi!
I found there are some redundancy in BddVariableSet::new, this PR optimized that function in two ways:

  • Using Iterator and collect, rather than Vec::push andHashMap::insert
  • Directly build BddVariableSet.var_index_mapping, avoid BddVariableSetBuilder.var_names_set

I add test function to validate the correctness as well as performance, here are the results

---- _impl_bdd_variable_set::tests::bdd_new_performance stdout ----
New BddVariableSet::new runtime: 18.004839ms
Old BddVariableSet::new runtime: 35.596261ms

Hoping that looks good to you

Copy link

codecov bot commented Dec 22, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 90.81%. Comparing base (e805cd3) to head (bc41250).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/_impl_bdd_variable_set.rs 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
- Coverage   90.91%   90.81%   -0.11%     
==========================================
  Files          27       27              
  Lines        2158     2167       +9     
==========================================
+ Hits         1962     1968       +6     
- Misses        196      199       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zao111222333 zao111222333 changed the title Optimize BddVariableSet::new Optimize BddVariableSet::new, 2x speedup Dec 22, 2024
@daemontus
Copy link
Member

Thank you! This looks good. We never really thought to optimize the BddVariableSet constructor because it usually isn't the bottleneck, but this is certainly a useful change :)

@daemontus daemontus merged commit 56a8a2e into sybila:master Dec 23, 2024
5 of 7 checks passed
@daemontus
Copy link
Member

Should be published now as 0.5.23.

@zao111222333
Copy link
Contributor Author

Thank you so much for your review!

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