-
Notifications
You must be signed in to change notification settings - Fork 273
Optimize remove_level_2 #3559
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
Optimize remove_level_2 #3559
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.
No, this would break any work towards field sensitivity, which build_ssa_identifier_rec
takes care of.
What is field sensitivity? |
6e86875
to
4935a90
Compare
Cf. #2574: we would treat individual members of structs or arrays as separate entities in the SSA encoding for the purpose of field-level constant propagation and smaller SAT encodings. Especially for Java it should be highly beneficial. @smowton has poked me about it several times... |
It sounds interesting but I'm not sure this would be affected by this PR. I will investigate another way to improve how ssa_exprt's are used in symex. |
The code in |
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: 4935a90).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94340800
4935a90
to
bf87ff3
Compare
@tautschnig I've changed my approach to optimize the function, this version should be cleaner. I've also added a couple of commits to make the interface of these classes clearer. |
@@ -82,7 +82,7 @@ bool ssa_exprt::can_build_identifier(const exprt &expr) | |||
return false; |
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.
Commit message typo: "and probably shouldn't." -> "and probably shouldn't be part of it."
Unless I'm misreading this changes very little? Previously inline functions aren't anymore, a couple of functions are static rather than members, and a single "if-is-ssa-expr" test is eliminated? Not objecting, just checking if something has been missed out in shuffling the commits; it currently looks like a cleanup with perhaps 1% performance impact rather than an optimisation. |
This is mostly true. The essential change is the remove_level_2 simplification. I would expect more than 1% improvement; I will run some benchmarks to confirm that. |
bf87ff3
to
dfd511e
Compare
Yes, a get more than 5% improvement on my benchmarks. |
Just from removing that check? Impressive! |
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: dfd511e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94495991
dfd511e
to
3f4677f
Compare
It's more than a check because |
@tautschnig are you happy with the changes? |
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.
Ok, looks good to me except there may be further room for improvement by dropping one change as noted below.
src/util/ssa_expr.cpp
Outdated
@@ -114,5 +114,5 @@ void ssa_exprt::update_identifier() | |||
void ssa_exprt::remove_level_2() | |||
{ | |||
remove(ID_L2); | |||
update_identifier(); | |||
set_identifier(get_l1_object_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.
With this change: shouldn't you move it back to the header file as now everything can be inlined?
To lighten the header.
This is not used outside of the ssa_exprt class and shouldn't be part of the public interface.
This is only used in one function.
For ssa_exprt's this always remove_level_2
To reset the identifier we can just used the l1_object_identifier which is a cached version of the level1 identifier.
3f4677f
to
7114c57
Compare
The CI failure is caused by doxygen not being able to be downloaded and installed |
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: 7114c57).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/94754125
Instead of rebuilding the identifier from scratch when we remove the level 2 of the ssa_exprt, we can just strip the suffix, which is more efficient. On benchmarks I ran locally (70 methods from tika) this has improved the execution time of symex by about 8% (from 77.2 sec to 70.8).