Use type index instead of type name for CompositeData#1019
Conversation
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
This reverts commit c362a62. Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
This reverts commit 5610321. Signed-off-by: Luca Della Vedova <lucadv@intrinsic.ai>
681ad79 to
38ac5aa
Compare
|
I tested it with
before this PR with this PR @ 38ac5aa There does seem to be an improvement! side note: I also tested it with 09c06ea before the unordered_map commit was reverted and the results were worse |
|
I think the most obvious change is that the large |
azeey
left a comment
There was a problem hiding this comment.
This is definitely an API break since the CompositeData type is meant to be inherited. Any downstream users who inherited from it to create their own types similar to ExpectData will be affected. So, strictly speaking, this should not be backported. However, I highly doubt anyone is doing that. If it was a large performance improvement, I wouldn't hesitate, but it is modest. I'd appreciate a second opinion from @scpeters
If this only modified |
|
Okay, let's not backport it then. |
🎉 New feature
Perf improvement.
CC @cheriehu
Summary
When contacts are enabled, using a
std::stringfor type name causes the construction + destruction ofMapOfDatato be very expensive because we need to allocate + deallocate astd::stringfor each entry in the map and, I believe, one map is allocated for each contact data.This PR changes it to
type_index, which, according to cppreference, is meant exactly to be used as a key type for associative containers (which is what we have here).I think this is not a big breakage since, according to the comment, the type is only public to allow friend classes to use it, not really because it's part of the public API.
It will technically break users that used the public type, as well as users that iterated on it and expected a stable alphabetical order, but I'm not sure how common these use case are.
Backport Policy
Read the above on the technical breakage.
Test it
This starts to be more of a bottleneck for simulations with contacts after the in-flight optimizations landed, specifically:
Checklist
codecheckpassed (See contributing)Generated-by: Gemini 3