-
Notifications
You must be signed in to change notification settings - Fork 274
Use sharing_mapt to store propagation map #4464
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
Use sharing_mapt to store propagation map #4464
Conversation
There was a problem hiding this 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: 496eb15).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106435134
Some stats for SV-COMP's ReachSafety-ECA:
Lookups in the propagation map are more expensive (as expected), but merging and cloning is a lot cheaper (as intended). |
src/goto-symex/goto_state.cpp
Outdated
@@ -86,7 +89,10 @@ void goto_statet::apply_condition( | |||
increase_generation( | |||
l1_identifier, l1_lhs, previous_state.get_l2_name_provider()); | |||
|
|||
propagation[l1_identifier] = rhs; | |||
if(propagation.has_key(l1_identifier)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to just give sharing_mapt
a primitive set
operation to save the double lookup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danpoe maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend to use find(l1_identifier)
here and then check that rhs
is different from the current value in the map, and only then do the replacement. When using this idiom a separate set()
method should be unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/goto-symex/goto_state.cpp
Outdated
@@ -86,7 +89,10 @@ void goto_statet::apply_condition( | |||
increase_generation( | |||
l1_identifier, l1_lhs, previous_state.get_l2_name_provider()); | |||
|
|||
propagation[l1_identifier] = rhs; | |||
if(propagation.has_key(l1_identifier)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend to use find(l1_identifier)
here and then check that rhs
is different from the current value in the map, and only then do the replacement. When using this idiom a separate set()
method should be unnecessary.
src/goto-symex/goto_symex_state.cpp
Outdated
propagation[l1_identifier] = rhs; | ||
{ | ||
if(propagation.has_key(l1_identifier)) | ||
propagation.replace(l1_identifier, rhs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if rhs
is different from the value already in the map (see above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
This one made almost no difference to our Webgoat lesson, I expect because generally the value-set is much bigger, but if we merge #3619 then that will no longer hold and this will be more important. |
Here are some results for the runtime of symex only, with Overall with sharing it was 9% slower, including the changes to |
496eb15
to
be7d917
Compare
@danpoe As #4463 is merged I have rebased this one. Would you (and possibly also @romainbrenguier and @smowton) mind doing another benchmarking run to see where we are? |
There was a problem hiding this 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: be7d917).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/106873800
It's probably best to put this on hold and look at other performance improvements first. It may also become a lot more relevant once we have field sensitivity in place as propagation maps will then likely be larger. |
Yep, that's also the conclusion we reached with @danpoe. |
72870e4
to
3bb8488
Compare
There was a problem hiding this comment.
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: 3bb8488).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107164126
Status will be re-evaluated on next push.
Common spurious failures include: 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); compatibility was already broken by an earlier merge.
3bb8488
to
f59007d
Compare
Needs |
goto-symex copies a state, which contains a propagation map, at each branching point. The paths originating at that branch point typically share most of the constants being propagated. Thus the copy is unnecessarily expensive, and so is the merge at the next join point, which will also result in one of the propagation maps to be destroyed. With sharing_mapt, the copy has constant cost, and the cost of destruction only depends on the size of the delta.
f59007d
to
32dc6d6
Compare
Thank you!! Done. Based on @smowton's data I'm inclined to merge this once CI passes. |
goto-symex copies a state, which contains a propagation map, at each
branching point. The paths originating at that branch point typically
share most of the constants being propagated. Thus the copy is
unnecessarily expensive, and so is the merge at the next join point,
which will also result in one of the propagation maps to be destroyed.
With sharing_mapt, the copy has constant cost, and the cost of
destruction only depends on the size of the delta.