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

Avoid a copy on full vector replacement by using std::move. #190

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

plietar
Copy link
Member

@plietar plietar commented Mar 5, 2024

When a queued update replaces an entire variable, we can re-use the vector contained in the update by moving it over, instead of copying it.

This situation is actually pretty common in malariasimulation, where exponentially decaying variables are entirely overwritten at each time step. This change speeds up the simulation by about 5% for a 1M population.

When a queued update replaces an entire variable, we can re-use the
vector contained in the update by moving it over, instead of copying it.

This situation is actually pretty common in malariasimulation, where
exponentially decaying variables are entirely overwritten at each time
step. This change speeds up the simulation by about 5% for a 1M
population.
@plietar plietar requested a review from giovannic March 5, 2024 19:50
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.12%. Comparing base (c9cdee3) to head (7de77db).
Report is 18 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #190      +/-   ##
==========================================
- Coverage   96.28%   96.12%   -0.16%     
==========================================
  Files          36       36              
  Lines        1722     1832     +110     
==========================================
+ Hits         1658     1761     +103     
- Misses         64       71       +7     

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

@plietar plietar merged commit 64d4c6c into mrc-ide:dev Mar 7, 2024
8 checks passed
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