metadata: improved performance#8942
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8942 +/- ##
==========================================
+ Coverage 83.27% 83.33% +0.05%
==========================================
Files 417 417
Lines 32986 33024 +38
==========================================
+ Hits 27468 27519 +51
- Misses 4096 4101 +5
+ Partials 1422 1404 -18
🚀 New features to boost your workflow:
|
|
From the benchmarks, v2 clearly improves Do you think this approach is worth merging as-is? If it makes sense, I can consolidate the current implementation into a single internal structure (just changing the underlying layout), or explore shaping this into part of a future metadata v2 API. |
|
Thanks for the PR, @ktalg! We’re currently focusing our resources on other priorities and try to avoid keeping drafts open in the interim. I'll close this for now, but we appreciate the effort. Let's revisit this down the road when we have more cycles to review! |
Addresses: #8860
Description
This PR introduces an experimental
v2implementation for outgoing metadata append handling.The goal here is not to replace the current implementation yet, but to validate an alternative internal structure and measure its performance characteristics.
The main idea is to avoid copying the entire append history on every
AppendToOutgoingContextcall.Background
The current implementation stores appended kv pairs in a
[][]stringslice. Every time we append:So each append copies the full append history.
This means:
What v2 does
In
v2, I changed the append storage to a persistent linked structure:Each append:
So append becomes effectively O(1) per call instead of O(n) with respect to append depth.
Complexity comparison
Where:
M= number of base metadata entriesN= total number of appended kv pairsImportant note:
FromOutgoingContextstill builds a newMDand copies values, so its asymptotic complexity remains unchanged in v2.Benchmark Results
Why append improves but from does not
Append improves because:
From does not significantly improve because:
MDSo the dominant cost of
FromOutgoingContextremains unchanged.Notes
This is currently experimental and meant for performance validation.
If we want to significantly improve
FromOutgoingContext, we would likely need:Happy to iterate based on feedback.