-
Notifications
You must be signed in to change notification settings - Fork 274
Change sharing map so that leafs can be directly attached to internal nodes #4685
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
On a set of methods from Apache Tika, the sum of the runtimes of the sharing map methods (timing just those) improved by 28%. Overall symex was 7% faster. |
4fd5b3d
to
6ac45f2
Compare
src/util/sharing_map.h
Outdated
typedef sharing_node_leaft<key_type, mapped_type> leaft; | ||
|
||
typedef sharing_node_baset baset; | ||
typedef sharing_nodet<key_type, mapped_type> innert; |
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.
(random line) commit message: where -> were :p
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.
LGTM (at moderate depth, haven't walked through the algorithms in detail to make sure there are no missing cases). Surprised not to see any updates to the top-level docs for the data structure though?
src/util/sharing_node.h
Outdated
@@ -70,14 +69,14 @@ const T *as_const(T *t) | |||
|
|||
// Inner nodes (internal nodes or container nodes) |
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.
Comment out of date now there are 3 possibilities?
src/util/sharing_map.h
Outdated
|
||
return lp; | ||
} | ||
leaft *get_leaf_node(const key_type &k); |
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.
(random line) commit message: leafs -> leaf
src/util/sharing_map.h
Outdated
|
||
key >>= chunk; | ||
if(ip->is_leaf()) |
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.
These are mutually exclusive, right? If so use else if
to clarify that.
src/util/sharing_map.h
Outdated
continue; | ||
} | ||
|
||
if(ip->is_leaf()) |
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.
else if
src/util/sharing_map.h
Outdated
num--; | ||
|
||
return; | ||
} | ||
|
||
if(ip->is_container()) |
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.
else if
8341802
to
d4d4ca5
Compare
src/util/sharing_map.h
Outdated
|
||
INVARIANT( | ||
!value_equalt()(as_const(lp)->get_value(), m), | ||
!value_equalt()(as_const(lp).get_value(), m), |
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.
Visual Studio complains that the use of as_const
is ambiguous here. You might have add/use a static cast here.
e7a5cf1
to
8c2b37e
Compare
Previously the leaf nodes were a separate type, and internal nodes and container nodes were represented by the same type. This changes the representation such that all nodes are represented by sharing_nodet. This will allow an internal node to directly point to a leaf node (instead of having to point to a container node which in turn points to a leaf node).
…haring map This adapts the methods for the case where a leaf can directly be attached to internal nodes.
Adapt get_view() and get_delta_view() for the case where a leaf node is directly attached to an internal node.
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: e7a5cf1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/112914521
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.
12e4945
to
872f203
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: 872f203).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/112923269
872f203
to
c7126b8
Compare
…g ones The shape of a sharing map is now different than before, as now leafs can be directly attached to internal nodes. This adapts the various unit tests that check that the map has a certain shape.
Previously some methods returned a pointer but would never return nullptr. This changes their return type to references instead.
Previously there existed a separate leaft type. Now all nodes are of the type sharing_nodet<...> (of which nodet is an lias). This replaces all node types by nodet.
When destructt::destruct() of a small shared n-way pointer is called, it first determines the type of its pointee. For example, if the parameter pack Ts... is instantiated to T1, T2, T3, then it first checks if the pointer points to T3, then to T2, etc. Thus, the least checks are performed if it is most likely that the pointer points to an object of type T3, then T2, etc.
Update the documentation to reflect the fact that the sharing map is now a variable-height tree.
Since the sharing map is now a variable-height tree, the best case complexity of various operations has changed.
c7126b8
to
d438341
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: d438341).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/112940281
Previously all leafs were stored in a linked list. However, this was unnecessary as collisions can occur only between nodes at the bottom of the tree. Now only leafs at the bottom are stored in a linked list, and all other leafs are direct successors of internal nodes.