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.
This tries to make use of the rkyv
CopyOptimize
attribute that can guarantee memcpy-able structs are indeed just that, rather then iterating over each element in the vector.This ran into one oddity however, the archived layout of
QbvhNode
is smaller then the regular layout (128 vs 124 bytes), this is becauseQbvhNode
contains quite a few padding bytes.QbvhNodeFlags
isu8
NodeIndex
has au8
memberBoth of those cause a (normally) 121-bytes struct to get blown up to 128 bytes.
In this PR I've hackfixed/worked around this issue by making QbvhNodeFlags u64 which obviously isn't what anybody would want, however since I'm not familiar with this project I'd like to open the discussion about what to do with this.
It seems likely that
QbvhNode
needs to be somehow cache-line aligned (which it is at the moment), but it might be nice to mark the padding bytes inNodeIndex
andQbvhNode
explicitly so it's clear where in the node one can stuff some additional info.Removing the
CopyOptimize
is not the end of the world; but in this case having it speeds up rkyv serialization by about 2x.