perf: Optimize mutable mesh partition lookup and bulk vertex copying#721
Open
InboraStudio wants to merge 2 commits into
Open
perf: Optimize mutable mesh partition lookup and bulk vertex copying#721InboraStudio wants to merge 2 commits into
InboraStudio wants to merge 2 commits into
Conversation
perf(mutable_mesh): replace linear partition scan with O(log N) upper_bound perf(mutable_mesh): use memcpy for bulk vertex copies in CopyVertexIntoPartition feat(geometry): expose MutRawVertexData for fast zero-overhead memory transfers
sfreilich
requested changes
Jun 30, 2026
sfreilich
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for these improvements! One slight suggestion about naming.
| absl::Span<const std::byte> RawVertexData() const { return vertex_data_; } | ||
|
|
||
| // Returns the mutable raw data of the mesh's vertices. | ||
| absl::Span<std::byte> MutRawVertexData() { return absl::MakeSpan(vertex_data_); } |
Collaborator
There was a problem hiding this comment.
Can this be named MutableRawVertexData? That's more consistent with naming elsewhere.
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.
this PR introduces targeted performance optimizations for intensive stroke generation and mesh updates, resolving known algorithmic bottlenecks.
key changes:
MutableMultiMesh::GetPartitionTriangleto usestd::upper_boundfor binary search, eliminating the O(N) linear scan across partition bounds.MutRawVertexData()toMutableMeshto provide safer, low-level access to the underlying byte array, enabling zero-overhead memory transfers.SetFloatVertexAttribute) inside hot loops inCopyVertexIntoPartitionwith directstd::memcpyof the vertex byte stride, significantly accelerating bulk mesh modifications.