Review suggestions for PR 14546#1
Merged
florianl merged 8 commits intoFeb 23, 2026
Merged
Conversation
Per the proto spec [1], key and key_ref are mutually exclusive on the wire. Without clearing Key after setting KeyRef, both fields would be serialized, violating the MUST NOT constraint and wasting bytes. [1] open-telemetry/opentelemetry-proto#733
OTLP profiles received are expected to use dictionary encodings on the wire. Optimizing the unmarshal performance for payloads without dictionary encoding is therefor targetting a scenario that is unlikely to be encountered in the wild. More importantly, the optimization makes the implicit assumptions that payloads will always either use dictionary encoding for all resource attributes or regular encoding. This is currently currently not being proposed [1], and would seem overly pedantic to enforce. Meanwhile there is the risk of false positives, so completely remove the optimization. Remove the marshal optimization for now as well, but see follow-up commit for restoring it in a different way. [1] open-telemetry/opentelemetry-proto#733
Optimize MarshalProfiles for the case where a profile doesn't contain
any non-dictionary references. This is the case for profiles that
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/collector/pdata/pprofile
cpu: Apple M1 Max
│ /tmp/before.txt │ /tmp/after.txt │
│ sec/op │ sec/op vs base │
MarshalProfiles/small-10 2.024µ ± 4% 1.686µ ± 6% -16.72% (p=0.002 n=6)
MarshalProfiles/medium-10 142.3µ ± 5% 143.9µ ± 4% ~ (p=0.132 n=6)
MarshalProfiles/large-10 4.212m ± 2% 4.237m ± 8% ~ (p=0.240 n=6)
geomean 106.7µ 100.9µ -5.39%
│ /tmp/before.txt │ /tmp/after.txt │
│ B/op │ B/op vs base │
MarshalProfiles/small-10 2.039Ki ± 0% 1.125Ki ± 0% -44.83% (p=0.002 n=6)
MarshalProfiles/medium-10 73.79Ki ± 0% 72.00Ki ± 0% -2.42% (p=0.002 n=6)
MarshalProfiles/large-10 2.019Mi ± 0% 2.016Mi ± 0% -0.16% (p=0.002 n=6)
geomean 67.76Ki 55.09Ki -18.70%
│ /tmp/before.txt │ /tmp/after.txt │
│ allocs/op │ allocs/op vs base │
MarshalProfiles/small-10 4.000 ± 0% 1.000 ± 0% -75.00% (p=0.002 n=6)
MarshalProfiles/medium-10 4.000 ± 0% 1.000 ± 0% -75.00% (p=0.002 n=6)
MarshalProfiles/large-10 4.000 ± 0% 1.000 ± 0% -75.00% (p=0.002 n=6)
geomean 4.000 1.000 -75.00%
Replace weak assertions (NotNil + Len check on ResourceProfiles) with proto.Equal for full semantic comparison of round-tripped data. The previous check would pass even if attributes, dictionary entries, profile contents, or other fields were corrupted during the round-trip.
Call convertProfilesToReferences before JSON marshaling so attribute keys and values are transmitted as string table references. Call resolveProfilesReferences after JSON unmarshaling so the pdata API works transparently with resolved strings.
1c5eb78 to
231f4ff
Compare
florianl
approved these changes
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
See open-telemetry#14546