Add optional wordvec feature for RelationshipSourceCollection #21513
+143
−0
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.
Objective
Add a more memory-efficient relationship source collection data structure for relationships with up to one child most of the time.
Solution
Introduces a new optional dependency
wordvec
, under the featurewordvec
, such thatcan be used to substitute
where the former only takes 16 bytes instead of 24 bytes with comparable performance to SmallVec, particularly 20%-40% when used as
Vec<WordVec<Entity, 1>>
to index other entities, but 40% slower during single-item pushing.Accessing

Vec<X<usize>>
forX = Vec/ThinVec/SmallVec/WordVec
(withN = 1
) wherevec.len() == 1000 && vec[i].len() == 1
fori
in 0 to 1000 (effectivelyQuery<&Children>.iter().flatten().for_each(|e| *u64_query.get_mut(e).unwrap() += 1)
):Pushing 1, 2, 3 in order to

X<u16>
withN = 3
:Testing
The tests for SmallVec implementation in
relationship_source_collection.rs
are duplicated for WordVec as-is.