Skip to content

merge_value_sets: Avoid assignment when actually values can be moved - #4169

Merged
tautschnig merged 1 commit into
diffblue:developfrom
tautschnig:opt-swap
Mar 2, 2019
Merged

tautschnig merged 1 commit into
diffblue:developfrom
tautschnig:opt-swap

Conversation

@tautschnig

@tautschnig tautschnig commented Feb 12, 2019 •

Copy link
Copy Markdown
Collaborator

We don't need the contents of the source anymore. Running on SV-COMP's
ReachSafety-ECA, this saves 741s, which is approximately 9% of the runtime of merge_goto.

  • 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.

Comment thread src/goto-symex/goto_symex.h Outdated
void merge_gotos(statet &);

virtual void merge_goto(const goto_statet &goto_state, statet &);
virtual void merge_goto(goto_statet &goto_state, statet &);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure what's happening here because there is no documentation. If the goto_state is not supposed to be used afterwards then it would be good to make it clear, either by documenting or in the type, by forcing the argument to be movable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fair, I'll work on adding documentation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Documentation added.

Comment thread src/goto-symex/symex_goto.cpp Outdated
dest.value_set=src.value_set;
// we don't actually need dest.value_set anymore, leave cleanup to later
// cleanup of goto states
dest.value_set.swap(src.value_set);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why swap and not move?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll try to take a look whether adding a move operator would be as easy.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done (just required also default-declaring a copy constructor).

@tautschnig tautschnig self-assigned this Feb 12, 2019

@allredj allredj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚫
This PR failed Diffblue compatibility checks (cbmc commit: d951590).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100661522
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

@allredj allredj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@smowton smowton left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Formalise this with a move-ref and this lgtm

You may also be interested in @JohnDumbell is currently separating the concepts of fresh-l2-name (global) and current-l2-name (local), so that the L2 renaming map can be straightfowardly moved as well.

Comment thread src/goto-checker/symex_bmc.h Outdated
override;

void merge_goto(const goto_statet &goto_state, statet &state) override;
void merge_goto(goto_statet &goto_state, statet &state) override;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If goto_state is indeed dying then we should pass a goto_statet &&

@tautschnig

Copy link
Copy Markdown
Collaborator Author

I have incorporated all the feedback and have now triggered another profiling run just to make sure this is still working as expected. @kroening @peterschrammel either of you will need to review this as well.

Comment thread src/goto-symex/goto_symex.h Outdated

// gotos
/// Merge all branches joining at the current program point at the current
/// program point. It will apply \ref merge_goto for each goto state (each of

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The end of the first sentence is repeated.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oops, thanks, fixed.

if(state.guard.is_false() && !goto_state.guard.is_false())
state.value_set = std::move(goto_state.value_set);
else if(!goto_state.guard.is_false())
state.value_set.make_union(goto_state.value_set);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would also make sense for make_union to not take a const ref, and use move instead. But that's maybe for another pull request.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Making this impactful is a bigger task, because the internal representation of a value set is reference counted. I'll leave this for another time.

We don't need the contents of the source anymore. Running on SV-COMP's
ReachSafety-ECA, this saves 741s, which is approximately 9% of the runtime of
goto_symext::merge_goto.

@allredj allredj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚫
This PR failed Diffblue compatibility checks (cbmc commit: 6c9937c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100793036
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.

@allredj allredj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tautschnig

Copy link
Copy Markdown
Collaborator Author

@kroening and/or @peterschrammel would you mind taking a look at this one? It's just +25/−21 and is already coming up in other PRs (#4199).

@tautschnig
tautschnig merged commit b4f65c8 into diffblue:develop Mar 2, 2019
@tautschnig
tautschnig deleted the opt-swap branch March 2, 2019 06:21
@tautschnig
tautschnig restored the opt-swap branch December 27, 2020 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants