-
Notifications
You must be signed in to change notification settings - Fork 440
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
Can the API avoid returning shared_ptr<Span> #828
Comments
Same comment should apply for "Baggage" as well. It should allow an alternative implementation (even though is not a proper implementation but could be a header replace) that does not require Baggage to be heap allocated and refcounted. |
We (Google) would be a fan of this change, giving us freedom to control performance going forward with differing implementations |
This should be doable. I'm not sure if we can preserve the ability to automatically end a span when it is deallocated (or goes out of scope). We might end up requiring explicit calls to |
You can achieve exactly the same behavior by having internally a |
Had a quick look into span api code, the problem I see here is that For the rest of the components like Baggage / TraceState, we can use the Pimpl idiom to get rid of returning shared_ptr as implemented here: #836 |
Just to add on top of the above comment, while we can add a |
Could we add a new API to support returning pointer/reference to |
One possible approach for this, which can be implemented very easily: Return Anyway, if we decide to go without using |
@lalitb can you please explain a bit more
What is the difference in your baggage prototype from ABI compatibility? If you change the current Baggage class is it not the same? |
Returning Though you are correct for the baggage prototype, as most of the implementation changes would happen in |
Can we have an implementation that performs the following:
By the way, ETW exporter is a "streaming" implementation. We can do measurements to tell how big the overhead is of the My biggest concern is refactoring a major piece something that reached |
The solution would depend on what we are trying to achieve here by removing ABI stable smart-pointer from API surface (sorry but I am still trying to get more clarity):
|
Ok, invested some time in prototyping span creation api to return Existing api ( using shared_ptr):
new api returning
After doing multiple iterations, haven't seen a significant difference in performance in both scenarios. As we get rid of shared_ptr, there is extra overhead to manage the cleanup of Span from Context once Span gets deleted. Another thing to notice is that there is a significant performance difference between Span creation with and without Scope (first two readings taken from either of the above scenarios), and it increased further with nested spans ( 3 reading above). This means we should revisit our existing linked-list / stack data structure used to manage context/spans. I will create a separate issue to investigate that, We can discuss this in the next community meeting. ps. If you would like to review the changes done for conversion to Code used for benchmarking: |
So if the new proposed approach degrades perf of span creation x1.75 times, and/or does not improve performance overall - for the sum across all tests (not a good metric though), is worse - because of
Why would we be doing that again? I think |
This was discussed in the last weekly meeting. After evaluating the current benchmark results and comparing it with that of
@bogdandrutu - please let us know if you see any concerns. We can keep this issue open and tag it for post-GA accordingly. |
@lalitb |
@manushawijekoon - Not sure what you mean by the thread un-safe implementation of SDK as concurrency at API level is one of the objectives of specs ( https://github.com/open-telemetry/opentelemetry-specification/blob/b46bcab5fb709381f1fd52096a19541370c7d1b3/specification/trace/api.md#concurrency ). Regarding |
This will limit its application in low latency systems.
However that spec didn't mention anything about API concurrent for metrics
- but I guess eventually that will be the case also.
Here is a nice blog about thread contention.
https://travisdowns.github.io/blog/2020/07/06/concurrency-costs.html
I am talking about level 0 (or even lower) type implementations based on
the terminology of the above blog.
…On Wed, Oct 13, 2021 at 3:43 AM Lalit Kumar Bhasin ***@***.***> wrote:
@manushawijekoon <https://github.com/manushawijekoon> - Not sure what you
mean by the thread un-safe implementation of SDK as concurrency at API
level is one of the objectives of specs (
https://github.com/open-telemetry/opentelemetry-specification/blob/b46bcab5fb709381f1fd52096a19541370c7d1b3/specification/trace/api.md#concurrency
).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#828 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK4QRXQUV53XJ4JTNQHMIL3UGSXJJANCNFSM46IBDCEQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
@manushawijekoon - Thanks for the link. Just to let you know,
|
This issue was marked as stale due to lack of activity. It will be closed in 7 days if no furthur activity occurs. |
Closed as inactive. Feel free to reopen if this is still an issue. |
keeping this open. |
the ceph project will also be interested in using non shared_ptr spans. |
@yuvalif - Do you have more details, which part of the Span life cycle has a detectable impact - creation, populating, or export/end? How you did these non-shared span tests, it would be interesting to reproduce this locally. Meanwhile, there is ongoing work on adding benchmark tests as part of CI (#1170) to get more stats. |
our main focus (for now...) is to test the no-op tracer and no-op span (we want to make sure that there is no performance degradation when the feature is disabled). this means that the only cost is with creating and accessing the spans (as these are no-op spans they don't do anything else). our open telemetry based tracing framework is here: below are links for our benchmark testing. we use an S3 client called hsbench that sends PUT and GET requests to our system. these requests are going through both the radosgw and OSD daemons.
we also did deeper perf analysis (this is harder to share), where creating the spans and the "Get" operation on the shared_ptr stand out as the difference between the 2 runs. |
Thanks, @yuvalif for the details. Just to clarify the results:
So on average, there is 7.4 - 7.2 = 0.2 ms latency added with no-op tracer/span for ~15 spans? Have you looked into the span creation benchmark tests at api level (using NoopTracer and NoopSpan) here? Though we still need to integrate them in CI, a quick test on them in my local setup gives these results:
Results for We have done a few tests returning span's unique_ptr and dropped it after not seeing substantial improvements. If you want to test that in your setup, I can send you the branch with the changes. Based on the results, we can start discussing adding the support? |
thanks @lalitb !
this would be great. we would try it out in our system and let you know if we see a difference in our setup. |
This issue was marked as stale due to lack of activity. It will be closed in 7 days if no furthur activity occurs. |
See: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/api/include/opentelemetry/trace/tracer.h#L39
By having this design an atomic ref-counting will always be needed. This will block in the future a possibly more performant "streaming" implementation where Span == SpanContext and all "record" apis will stream an event. The reason for "blocking" is because will still pay the refcounting and heap allocation cost even though is not needed.
The SDK can implement the Span by having an internal shared_ptr using a pimpl pattern.
The text was updated successfully, but these errors were encountered: