Add Index::merge_from + Index::insert exploits stuff for perf.#4086
Open
Add Index::merge_from + Index::insert exploits stuff for perf.#4086
Index::merge_from + Index::insert exploits stuff for perf.#4086Conversation
f8b2d98 to
923c9fb
Compare
923c9fb to
5b5e4f9
Compare
4dd9b9b to
3acf683
Compare
83357bd to
31c0059
Compare
31c0059 to
1677b36
Compare
gefjon
reviewed
Jan 22, 2026
| /// 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( |
Contributor
There was a problem hiding this comment.
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. |
Contributor
There was a problem hiding this comment.
Does cfg(test) necessarily imply cfg(debug_assertions)?
Comment on lines
+136
to
+137
| // SAFETY: The intersection is empty, so `dst ++ src` is also a set. | ||
| dst.append(&mut src); |
Contributor
There was a problem hiding this comment.
Do we need to potentially upgrade here to a Self::Large if the two sets combined meet some size threshold?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.