Revisit payload splitting strategy for Datadog Metrics destination. #327
Labels
area/memory
Memory bounds and memory management.
destination/datadog-metrics
Datadog Metrics destination.
effort/intermediate
Involves changes that can be worked on by non-experts but might require guidance.
type/enhancement
An enhancement in functionality or support.
Context
In #306, we added support for splitting request payloads in the Datadog Metrics destination when we detected that we had exceeded one of the (un)compressed payload size limits.
As part of this work, we took an approach where we incrementally encoded each metric into a single scratch buffer, while also writing each encoded metric into the compressor. My thinking went: when it comes time to split a request due to exceeding a limit, all we'll need to do is re-compress our existing encoded metrics, and we'll skip having to re-encode them all over again.
However, what I failed to consider was how this would greatly increase the component's memory bounds. Since we're now potentially holding the entire uncompressed payload in the scratch buffer, the scratch buffer can be as large as the uncompressed limit.. which when accounting for having a sketch-specific and series-specific request builder, means we could have two persistent allocations totaling up to ~65MiB... which is pretty suboptimal.
We should try and rethink our approach here, balancing the overhead of having to re-encode a bunch of metrics with the frequency at which payload splitting even occurs.
The text was updated successfully, but these errors were encountered: