Optimize remove_level_2#3559
Conversation
tautschnig
left a comment
There was a problem hiding this comment.
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 |
allredj
left a comment
There was a problem hiding this comment.
✔️
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.
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! |
allredj
left a comment
There was a problem hiding this comment.
✔️
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? |
tautschnig
left a comment
There was a problem hiding this comment.
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
| { | ||
| remove(ID_L2); | ||
| update_identifier(); | ||
| set_identifier(get_l1_object_identifier()); |
There was a problem hiding this comment.
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 |
allredj
left a comment
There was a problem hiding this comment.
✔️
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).