-
Notifications
You must be signed in to change notification settings - Fork 506
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
Tracer::Clone is at least 30% of the cost of Tracer::start, because of InstrumentationLibrary #1092
Comments
I would vote for this, I did notice this while reviewing logging SDK (#788 (comment)), and find it unnecessary to clone InstrumentationLibrary and Resource for each log getting exported. Though final say would be by approvers/maintainers :) |
I think similar optimization can be done for Resource too? |
For sure. I'm working on a change to make |
It used to be a literal but we received feedback that some use case populate the value during runtime. (See #666) |
I think the |
Here's a flame graph of starting portion of a span from the sdk's

trace
benchmark.Cloning a
Tracer
needs to be cheap, because we do it when creating new spans.But,
InstrumentationLibrary
contains 3Cow<'static, str>
instances and aVec<KeyValue>
for a total of 120 bytes per instance. All of that needs to get copied when Cloning one.I think we need to focus on the design of the
InstrumentationLibrary
type, as it's in the api. To me, it feels like it is (or should be) immutable and needs to be cheaply cloneable, so my first thought was it should resemble something like anArc
wrapping an inner struct of 3 `static string slices and the optional vector of attributes.I'm willing to contribute at PR to change this but want to coordinate and get consensus before choosing an implementation path that might ultimately get rejected after putting in a bunch of work.
My first question is about the seeming preference for
Cow<'static, str>
rather than, sayArc<str>
for representing things like library name, version, and schema url, knowing that they are all fundamentally immutable. IOW, I'm confused for what scenario would ever want to mutate these, and hence need the "copy on write" functionality?The text was updated successfully, but these errors were encountered: