Box complex types in AnyValue enum (Improve perf by 10%, and size reduction by ~60%)#1993
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1993 +/- ##
=====================================
Coverage 75.1% 75.1%
=====================================
Files 122 122
Lines 20633 20642 +9
=====================================
+ Hits 15497 15506 +9
Misses 5136 5136 ☔ View full report in Codecov by Sentry. |
cijothomas
left a comment
There was a problem hiding this comment.
Thanks for continuing to make perf get better!
LGTM with a changelog entry.
Could you also share stress tests with memory stats to see if it can show the improvement in memory as well?
Here are the memory stats. PR: Main: , I think we can get better/detailed insights by integrating custom allocator (jemalloc) with the stress test |
Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com>
…uction by ~60%) (open-telemetry#1993) Co-authored-by: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
Fixes #1903
Changes
The AnyValue enum has been modified to box complex types, reducing the effective size of the enum for commonly used scenarios like integers and strings.
Existing:
Modified:
Since the size of an enum in Rust is determined by the size of its largest variant, boxing the complex types (which are rarely used) can reduce the effective size of the AnyValue enum for the more frequently used cases like integers and strings.
Size Comparison
Refer - https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9d2c7b8cc2a603afe23284816faae242
By boxing, the overall size of the enum is reduced, leading to potential performance improvements. Complex types already allocate
dataon the heap; boxing simply means that both thedataandmetadatawill now be heap-allocated.Performance Benchmark:
opentelemetry-sdk/benches - full-log-with-4-attributes
PR: 116.32 ns
Main: 127.22 ns
opentelemetry-appender-tracing - ot-layer-enabled
PR: 305.00 ns
Main: 325.00 ns
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes