Skip to content

Review suggestions for PR 14546#1

Merged
florianl merged 8 commits into
florianl:pprofile-refsfrom
felixge:pr-14546/resource-ref-attrs/review-1
Feb 23, 2026
Merged

Review suggestions for PR 14546#1
florianl merged 8 commits into
florianl:pprofile-refsfrom
felixge:pr-14546/resource-ref-attrs/review-1

Conversation

@felixge
Copy link
Copy Markdown

@felixge felixge commented Feb 21, 2026

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.
@florianl florianl merged commit 0455574 into florianl:pprofile-refs Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants