-
Notifications
You must be signed in to change notification settings - Fork 273
Do not unnecessarily break sharing during renaming #4286
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
Conversation
I think for review it would be nice to split the PR in three commits: on that makes rename_address return an optional, one for rename_type and one for rename_expr. |
5ef434d
to
7cf4875
Compare
Split into three commits done and rebased onto current develop - releasing for review. |
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: 7cf4875).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102536309
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: 5ef434d).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102537067
Status will be re-evaluated on next push.
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 compatibility was already broken by an earlier merge.
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.
Looks good -- my comments about redundant quality tests may in fact be subsumed by later commits.
Question: does this render the rename-required pre-pass redundant? Should we combine the two methods into one walk at this point?
Pattern question: mild preference for something that takes an exprt &
as at present, carefully turns that into a const exprt &
, uses that to determine if anything needs doing, and then writes to it if appropriate, rather than having the if(ret) val = *ret;
pattern at every callsite
I'm taking the liberty to mark this dependent-on-#4264. |
@tautschnig #4286 has been merged, and this needs rebasing |
7cf4875
to
6b8be6a
Compare
6b8be6a
to
0d1463c
Compare
Instead of editing the object in place, return an optional<typet> that is set if, and only if, a modification took place.
requires_renaming must not recurse into array subtypes in structs.
We return a renamed type if, and only if, renaming was necessary. Thus we can do the is-it-necessary and the actual renaming in a single pass.
…sses) Instead of editing the object in place, return an optional<exprt> that is set if, and only if, a modification took place.
Not all subexpressions (or types) change during renaming. Only actually write to the result when there was a change. This preserves sharing. Performance results for this and parts 1 and 2 of the renaming combined: On SV-COMP's ReachSafety-ECA benchmarks the time spent in goto_symex_state::rename(exprt &, ...) is now 1944 seconds, when previously it was 2326 seconds. On the other hand, the time spent in merge_ireps did not improve, the number of recursive operator== calls in fact was higher (6930718243 rising to from 5710509892). The time spent in goto_symex_statet::rename(typet &, ...) increases from 530 seconds to 568 seconds, which suggests there is room for improvement.
0d1463c
to
71aec16
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 71aec16).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/103873701
I'm currently running benchmarks of develop vs. this branch to back up these changes by performance data. If those do not yield any negative results I'm inclined to merge this as-is and do the cleanup proposed by @romainbrenguier and @smowton in follow-up work. |
Here are my profiling results (on ReachSafety-ECA from SV-COMP): In my opinion this is no clear indication either way. I think the approach of not breaking sharing is cleaner, but it's certainly no performance win by itself. @kroening @peterschrammel @romainbrenguier @smowton Can you please voice your opinions on whether we should do this or not? |
Since it doesn't have a positive impact on performances and makes the code more complicated, I would be in favor of not merging it. |
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'm "requesting changes" so that this doesn't get merged by mistake.
Agreed that the sharing breaking is a great thing, and it seems like it shouldn't be too difficult to get that without incurring a lot of extra cost tracking that. Could you find out if it reduces the lost time to return |
Closing as all this code has been substantially rewritten already and uses move semantics today. |
Not all subexpressions (or types) change during renaming. Only actually write to
the result when there was a change. This preserves sharing. On SV-COMP's
ReachSafety-ECA benchmarks the time spent in goto_symex_state::rename(exprt &,
...) is now 1944 seconds, when previously it was 2326 seconds. On the other
hand, the time spent in merge_ireps did not improve, the number of recursive
operator== calls in fact was higher (6930718243 rising to from 5710509892).
The time spent in goto_symex_statet::rename(typet &, ...) increases from 530
seconds to 568 seconds, which suggests there is room for improvement.
I will keep this PR in Draft status to make sure #3996 won't need a rebase.