Skip to content

Optimize calls to increase_counter #3554

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

Merged

Conversation

romainbrenguier
Copy link
Contributor

@romainbrenguier romainbrenguier commented Dec 10, 2018

increase_counter is always called after a lookup in the corresponding map, and performs two additional lookup, we can get rid of this redundancy by passing an iterator as argument.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • [na] The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • [na] White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me (but I'm not sure how much of an effect it actually has).

}
else
state.level1.current_names.emplace(
l0_name, std::make_pair(ssa, frame_nr));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Braces would be helpful here

@@ -38,10 +38,9 @@ struct symex_renaming_levelt
}

/// Increase the counter corresponding to an identifier
void increase_counter(const irep_idt &identifier)
static void increase_counter(const current_namest::iterator &it)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Would have been better to create two different commits for these two changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure which two changes you are talking about

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 1eb5181).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94207006

Taking an iterator instead of an identifier removes the need for a
precondition (thus avoiding a lookup) and can avoid an additional
lookup.
@romainbrenguier romainbrenguier force-pushed the optimize/symex-assignment branch from 1eb5181 to e71ca91 Compare December 10, 2018 15:46
@romainbrenguier
Copy link
Contributor Author

@tautschnig on my benchmarks the symex time went down by 9%

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: e71ca91).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94218134

@romainbrenguier romainbrenguier merged commit 4f5647d into diffblue:develop Dec 10, 2018
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.

3 participants