Skip to content

Add CoW base to value-set #3053

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

Closed

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Sep 26, 2018

  • Each commit message has a non-empty body, explaining why the change was made.
  • My contribution is formatted in line with CODING_STANDARD.md.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • 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.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Add support for a simple CoW base to value-set. This is intended to permit VSA of a function where there is a large global context which we expect to sparsely modify. I don't make any decisions here about how and why to use the facility -- my first stab will be snapshotting the state of the world after __CPROVER_initialize has run -- but simply add support for the feature.

value_sett::do_free would have been awkward to accommodate, but there didn't seem to be any way to actually use it (I can't find anything that creates a codet with statement == ID_free), so I removed this entirely on suspicion that it is dead code. @peterschrammel @tautschnig might disagree.

This means when the underlying datastructure changes we don't have to
update several users.
It appears to be impossible to create a free statement (as opposed to a call to
stdlib's free); therefore this path can't be exercised. All the better, since
updating everyone's pointers (rather than tracking allocated / deallocated status
with the object itself) is surely a mistake in any case.
This is a simple copy-on-write base, intended to allow cheap local analysis on top of a potentially
large, possibly mutable global state.
This ensures that in a simple case with constant and non-constant pointers to
the same target, the value-set domain appears to behave the same way for both, but
in fact optimises by avoiding storing the constant pointer.
Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

One minor note below, but the high-level feedback might be more important:

  1. I think this could be several PRs, some of the commits seem easy to merge without much discussion.
  2. Doing work to speed up value-set operations has been on my list for a long time (but surely hasn't happened...) - my thinking was to make use of sharing maps. Did you consider this and, if so, why did you rule it out?

/// \return a constant pointer to an entry if found, or null otherwise.
/// Note the pointer may be invalidated by insert operations, including
/// get_entry.
const entryt *find_entry(const idt &id) const;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would optionalt be a possibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personal preference: T * not optionalt<reference_wrapper<T>>

Copy link
Contributor

Choose a reason for hiding this comment

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

What about optionalt<T *>? It would more clearly express the intent and remove the role of nullptr as a sentinel value that can accidentally be dereferenced.

Copy link
Contributor

@allredj allredj left a 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: e8015b8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86048937

@smowton
Copy link
Contributor Author

smowton commented Sep 26, 2018

Sharing map: haven't looked at it in great detail; my loose impression was it was to be employed when there is arbitrary sharing between lots of closely-related trees, whereas for my plan "snapshot once after global init, then normal value_sett" that's overkill. Basically I expect I'll have an easier time debugging with this simple scheme than with an (at first glance) exceedingly complicated data structure.

@smowton
Copy link
Contributor Author

smowton commented Sep 26, 2018

(@tautschnig if you're not interested because it's not general enough then fair enough, I'll keep this in our fork, just putting this up to see what you think)

@tautschnig tautschnig self-assigned this Nov 10, 2018
@tautschnig
Copy link
Collaborator

Months later ... @smowton would you mind taking a look at tautschnig@e09a575 as that might solve the problem for you? (It'll require #4274 to compile, though.)

@tautschnig tautschnig assigned smowton and unassigned tautschnig Feb 25, 2019
@smowton
Copy link
Contributor Author

smowton commented Feb 25, 2019

@tautschnig that does look rather good. I haven't used this in symex our side, but I'll give this a go soon. Hadn't realised sharing-map has this delta-view concept, which sounds ideal.

@smowton
Copy link
Contributor Author

smowton commented Feb 25, 2019

Also I note to really get the benefit here, once @JohnDumbell has simplified the renaming maps they should work similarly, so that goto_statet is really cheap to both copy and compare.

@smowton
Copy link
Contributor Author

smowton commented Apr 11, 2019

Unnecessary now that we have value-sets backed by sharing_mapt.

@smowton smowton closed this Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants