Skip to content

Use the sharing map for the renaming level maps #4505

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

danpoe
Copy link
Contributor

@danpoe danpoe commented Apr 9, 2019

Use the sharing map for the renaming level maps current_names in symex_renaming_levelt. The code in this PR has a few issues which I'll fix once we've decided whether to merge it.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a 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.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@danpoe danpoe added Performance Optimisations do not merge Needs data This PR claims improvements that require further data to substantiate the claims. labels Apr 9, 2019
@danpoe
Copy link
Contributor Author

danpoe commented Apr 9, 2019

Here are some results for the runtime of symex only, with --unwind 1, on several methods from Apache Tika on which symex takes between 5 and 15 sec

Rplot
Overall with sharing it's 3% faster.

@danpoe
Copy link
Contributor Author

danpoe commented Apr 9, 2019

@smowton, @romainbrenguier Would you be able to try this out on your benchmarks too?

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.

Comments (including one blocking one) below; I've started performance experiments, will report on their results later on today.

if(
state.get_level2().current_names.find(ssa_expr.get_identifier()) ==
state.get_level2().current_names.end())
if(!state.get_level2().current_names.has_key(ssa_expr.get_identifier()))
Copy link
Collaborator

@tautschnig tautschnig Apr 10, 2019

Choose a reason for hiding this comment

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

Formatting looks messed up? (edit: just a GitHub artifact)

{
std::pair<ssa_exprt, unsigned> copy = r_opt->get();
copy.second = n;
level2.current_names.replace(l1_identifier, copy);
Copy link
Collaborator

Choose a reason for hiding this comment

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

std::move(copy)

@@ -776,16 +776,20 @@ ssa_exprt goto_symex_statet::add_object(
const irep_idt l0_name = ssa.get_identifier();
const std::size_t l1_index = index_generator(l0_name);

// save old L1 name, if any
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I appreciate that this comment has been removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Put back in

{
level2.current_names.erase(it);
level2.current_names.erase(l1_identifier);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this method should either be removed or else be used from drop_l1_name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other version is now using erase_if_exists() as suggested by @smowton

@@ -16,6 +16,8 @@ Author: Daniel Kroening, [email protected]
class ssa_exprt:public symbol_exprt
{
public:
ssa_exprt() : symbol_exprt("", typet()) {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is pretty much a show stopper: why is this needed? Presumably a side effect of how objects are created in a sharing map, but can the sharing map please be fixed instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe somewhere between @danpoe and @smowton: can you look into this and see whether we can get away without it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I'll take a look

Copy link
Contributor Author

@danpoe danpoe May 3, 2019

Choose a reason for hiding this comment

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

I was meaning to fix this once we have decided whether to merge this PR. Currently the sharing map creates a dummy object (using the default constructor of the stored value type) when for a delta_view_itemt the key is only in one of the maps. We can probably use an optionalt instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

#4612 is merged.

@tautschnig
Copy link
Collaborator

The results for my recent favourite ReachSafety-ECA are: 160 points scored with this patch, 156 points without this patch. Symex steps per second increase from 2978.24 to 2991.21. So that's overall an improvement, albeit not a groundbreaking one.

@romainbrenguier
Copy link
Contributor

On my benchmarks the total time went from 106.85 to 99.31 chart (2)

@tautschnig
Copy link
Collaborator

@danpoe @romainbrenguier Could you rerun your benchmarking now that field-sensitivity is merged? It's possible that the maps now actually get larger, and thus such changes may be more impactful.

}

/// Drops an L1 name from the local L2 map
void drop_l1_name(const irep_idt &l1_identifier)
{
level2.current_names.erase(l1_identifier);
if(level2.current_names.has_key(l1_identifier))
Copy link
Contributor

Choose a reason for hiding this comment

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

Now have erase_if_exists

auto it = current_names.begin();
for(const auto &pair : other)
current_namest::delta_viewt delta_view;
other.get_delta_view(current_names, delta_view, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

delta_view overestimates the keys that may differ, right? If so couldn't the replace below replace for no good reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Tested this with a long-running Webgoat analysis -- found before the changes it took ~200s, afterwards ~160s.

@danpoe
Copy link
Contributor Author

danpoe commented Apr 23, 2019

Here are some results for the runtime of symex only, with --unwind 1, on several methods from Apache Tika, after field-sensitivity was merged:

Rplot

Overall with sharing it's 3% faster.

Btw, I've also compared old symex vs. field sensitive symex and overall field-sensitive symex was 6.3X faster on the benchmarks.

@danpoe danpoe force-pushed the feature/use-sharing-map-for-renaming branch from 9edc38c to ba5b977 Compare April 29, 2019 09:44
@romainbrenguier
Copy link
Contributor

For my benchmarks it didn't seem to have a positive effect:
execution time on develop and sharing renaming (1)
Total time went from 73.86s to 77.218s

@smowton
Copy link
Contributor

smowton commented Apr 30, 2019

Now that field-sensitivity is in this makes even more of a difference, mostly in skipping the large number of new keys in the renaming map via a sparse delta_viewt. I suspect the benchmarks above aren't really seeing the benefit as they're micro-benchmarks, whereas these effects only really show up once the renaming map gets large.

@danpoe
Copy link
Contributor Author

danpoe commented May 3, 2019

@smowton Would you be able to re-run the benchmarks on the Webgoat analysis now that field-sensitivity has been merged?

@smowton
Copy link
Contributor

smowton commented May 3, 2019

Benchmark results for a long-running Webgoat analysis:

Develop: 77s
#4464: 57s
#4464 + #4505: 26s

@danpoe
Copy link
Contributor Author

danpoe commented May 7, 2019

Thanks everyone for the benchmarking and comments. So in summary on @romainbrenguier's benchmarks it's about 4% slower, on @smowton's benchmark it's about twice as fast, and on my benchmarks it's about 3% faster. So I'd be inclined to merge it once comments have been addressed and CI passes.

@danpoe danpoe force-pushed the feature/use-sharing-map-for-renaming branch from ba5b977 to f37b254 Compare May 7, 2019 16:09
@smowton
Copy link
Contributor

smowton commented May 7, 2019

CI failure is caused by the rebase, as other_m is now a pointer

@danpoe danpoe force-pushed the feature/use-sharing-map-for-renaming branch from f37b254 to c608c50 Compare May 7, 2019 16:30
@danpoe danpoe force-pushed the feature/use-sharing-map-for-renaming branch from c608c50 to 60dbcd9 Compare May 7, 2019 16:35
@danpoe danpoe merged commit 9dbac2e into diffblue:develop May 7, 2019
@danpoe danpoe deleted the feature/use-sharing-map-for-renaming branch June 2, 2020 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Needs data This PR claims improvements that require further data to substantiate the claims. Performance Optimisations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants