[Experiment] fastdto for MakePairLabels (on top of #1734) #1746
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Experimenting with tailored dto for #1734
*dto.LabelPairs are pretty bad. We got stuck with *dto.Metric in our API since the beginning. This is problematic with the notorious use of small objects and pointers everywhere and all structs are bigger to support unknown fields and parsing. We don't need any of this in client_golang - it's just overhead for us. We only need interim struct and fast encoding.
This is also the reason why we can't optimize #1734 further.
We always wanted to do move out, but we can't change dto.Metric use due to compatibility....
...unless we can (:
We could start introducing it slowly and then do
Write2(m fastdto.Metric)
or so API if we want (or release v2 client golang which I would love to avoid).Benchmarks are not ideal. I think it keeps the CPU adventage of #1734, but "reverts" the allocs to where they were.
I think for the next iteration we could try moving this cost to
Write
(so when collect is used). When collecting one could pool/reuse dto.Metrics OR useWrite2
with fastdto Metric 🤔