Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About the performance overhead of attribute deduplication in recordingSpan#snapshot #5130

Open
moonspirit opened this issue Mar 31, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@moonspirit
Copy link

moonspirit commented Mar 31, 2024

Problem Statement

I updated from 1.21 to 1.24, just found i can get noticeable performance improvement for setAttributes memory alloc, trace context inject/extract and other aspects.

But after profiling my rpc framework, i have some thoughts about deduplicating attributes in recordingSpan#snapshot.

To support Tail Sampling(sampling errors) , we have to sample all spans with RecordAndSample or RecordOnly, that means we need to store attributes for all spans, that makes recordingSpan#snapshot being a critical path.

here is a profiling frame graph which enables tail sampling and set sample fraction to 1/1024 (expect to be less overhead)

image

the profile show that The current cost of this part(attribute deduplication even all my attributes are unique, no duplications) is about the same as that of propagation.compositeTextMapPropagator.Extract.

I would expect this processing of snapshots can be optimized.

Proposed Solution

I would prefer to delay attributes deduplication when we decided to record and sample that span, that means we could delay the operation to SpanProcessor

Alternatives

Or provide an option not to deduplication attributes

@moonspirit moonspirit added the enhancement New feature or request label Mar 31, 2024
@dmathieu
Copy link
Member

dmathieu commented Apr 2, 2024

Do you have the same flame graph running on 1.21 that would show the difference between both versions? (maybe with 1.22 too?)

@moonspirit
Copy link
Author

moonspirit commented Apr 3, 2024

Do you have the same flame graph running on 1.21 that would show the difference between both versions? (maybe with 1.22 too?)

Hi, dmathieu, Here is the different graph for the same benchmark

otel v1.21
image

otel v1.24
image

the code is here https://github.com/moonspirit/grpc-tracing-bench
(grpc has bad performance for metadata.FromIncomingContext or peer.Peer.Addr.String())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants