Performance improvements in serialization#553
Conversation
The dynamic_cast here turned out to be quite costly. Replacing it by the variant like function, we see a ~10% cpu usage reduction in our use case. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
This gives another performance improvement of around 2% of cpu usage in our usage scenario. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com>
c56eee4 to
014c629
Compare
|
Pulls: #553 |
fujitatomoya
left a comment
There was a problem hiding this comment.
lgtm with green CI.
i would like to approval from @eboasson or someone else before merge.
biodranik
left a comment
There was a problem hiding this comment.
Thanks, LGTM
The change eliminates dynamic_cast and virtual functions' overhead by using the CRTP pattern https://en.cppreference.com/w/cpp/language/crtp.html
eboasson
left a comment
There was a problem hiding this comment.
LGTM (not that I am much of a C++ programmer)
Merging this is going to require some rework on #550. For that I only took the existing code and added a few variations and a few functions, so I am hopeful it is straightforward. The trouble is that I don't really know whether my hope is well-founded ("I am not much of a ..." &c.). Perhaps you could check @jmachowinski ?
|
@Mergifyio backport jazzy kilted |
✅ Backports have been createdDetails
|
* perf: Fixed high CPU usage due to dynamic_cast The dynamic_cast here turned out to be quite costly. Replacing it by the variant like function, we see a ~10% cpu usage reduction in our use case. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com> * perf: Replaced virtual functions by templates This gives another performance improvement of around 2% of cpu usage in our usage scenario. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com> --------- Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com> Co-authored-by: Janosch Machowinski <J.Machowinski@cellumation.com> (cherry picked from commit 5147e01)
* perf: Fixed high CPU usage due to dynamic_cast The dynamic_cast here turned out to be quite costly. Replacing it by the variant like function, we see a ~10% cpu usage reduction in our use case. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com> * perf: Replaced virtual functions by templates This gives another performance improvement of around 2% of cpu usage in our usage scenario. Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com> --------- Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com> Co-authored-by: Janosch Machowinski <J.Machowinski@cellumation.com> (cherry picked from commit 5147e01)
* perf: Fixed high CPU usage due to dynamic_cast The dynamic_cast here turned out to be quite costly. Replacing it by the variant like function, we see a ~10% cpu usage reduction in our use case. * perf: Replaced virtual functions by templates This gives another performance improvement of around 2% of cpu usage in our usage scenario. --------- (cherry picked from commit 5147e01) Signed-off-by: Janosch Machowinski <J.Machowinski@cellumation.com> Co-authored-by: Janosch Machowinski <jmachowinski@users.noreply.github.com> Co-authored-by: Janosch Machowinski <J.Machowinski@cellumation.com>
Description
Optimized functions that showed up in perf
Did you use Generative AI?
No