Component(s)
receiver/prometheusremotewrite
Describe the issue you're reporting
Description
Summary
When adding multiple key-value pairs to a pcommon.Map using PutStr(), the underlying slice undergoes frequent reallocations and copies, leading to significant memory overhead. In production workloads with high cardinality metrics/logs, this becomes a major performance bottleneck.
Evidence
Memory profiling (pprof) shows that Map.EnsureCapacity accounts for 27.17% (0.94GB) of total memory allocation, even though it's never explicitly called in application code:
flat flat% sum% cum cum%
0.94GB 27.17% 60.05% 0.94GB 27.17% go.opentelemetry.io/collector/pdata/pcommon.Map.EnsureCapacity
0.54GB 15.49% 75.55% 0.54GB 15.49% go.opentelemetry.io/collector/pdata/pcommon.value.SetStr
0.41GB 11.82% 87.36% 0.42GB 12.17% go.opentelemetry.io/collector/pdata/pcommon.Map.PutInt
Root Cause
The current PutStr implementation relies on Go's built-in append:
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Component(s)
receiver/prometheusremotewrite
Describe the issue you're reporting
Description
Summary
When adding multiple key-value pairs to a pcommon.Map using PutStr(), the underlying slice undergoes frequent reallocations and copies, leading to significant memory overhead. In production workloads with high cardinality metrics/logs, this becomes a major performance bottleneck.
Evidence
Memory profiling (pprof) shows that Map.EnsureCapacity accounts for 27.17% (0.94GB) of total memory allocation, even though it's never explicitly called in application code:
Root Cause
The current PutStr implementation relies on Go's built-in append:
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it. Learn more here.