-
Notifications
You must be signed in to change notification settings - Fork 677
Add Index::merge_from + Index::insert exploits stuff for perf.
#4086
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
base: master
Are you sure you want to change the base?
Conversation
f8b2d98 to
923c9fb
Compare
923c9fb to
5b5e4f9
Compare
4dd9b9b to
3acf683
Compare
83357bd to
31c0059
Compare
31c0059 to
1677b36
Compare
| /// The relation `key -> ptr` must not exist in the index. | ||
| /// Note that inserting `key -> ptr_other`, | ||
| /// where `ptr != ptr_other`, is legal. | ||
| fn insert_maybe_despecialize( |
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.
Why is this method not marked unsafe, when it has a Safety section in its docs and you're calling it with an unsafe block?
|
|
||
| #[cfg(test)] | ||
| fn insert_for_test(&mut self, key: Self::Key, ptr: RowPointer) -> Result<(), RowPointer> { | ||
| // SAFETY: proof obligation checked inside the method for debug builds. |
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.
Does cfg(test) necessarily imply cfg(debug_assertions)?
| // SAFETY: The intersection is empty, so `dst ++ src` is also a set. | ||
| dst.append(&mut src); |
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.
Do we need to potentially upgrade here to a Self::Large if the two sets combined meet some size threshold?
Description of Changes
This PR:
Index::merge_from(&mut self, src: Self), which mergessrcintoself. This will be used to speed up merging of transactions.Index::insertto exploit a property for improved performance in itself and inIndex::merge_from.(key, ptr)occurs twice. This was always the case, but now it is a safety invariant and exploited for performance. This then is bubbled up toMutTxIdand friends.API and ABI breaking changes
None
Expected complexity level and risk
4 - This touches both
Index::insert,Table, andMutTxIdin terms ofunsafe.Testing
Index::insert.merge_from_is_unionis added that comprehensively exercisesIndex::{insert, merge_from, can_merge}together and for all index kinds and uniqueness.