Add Index::merge_from + Index::insert exploits stuff for perf.
#4086
+880
−180
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.