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

DO_NOT_MERGE: Try to avoid pointers in repeated fields #2002

Closed
wants to merge 2 commits into from

Conversation

bogdandrutu
Copy link
Member

@bogdandrutu bogdandrutu commented Oct 23, 2020

In this experiment, the repeated InstrumentationLibrarySpans field is marked as not nullable:

  • There is one important breaking change, after Append is called, changing the object that was used to call Append will not reflect into changes in the appended object (essentially we do a copy).
  • IsNil will always return false.
  • We can easily and optimal provide now a constructor with capacity, instead of New + Resize.
  • Calling Append multiple times is more innefficient than Resize/fill object. Need to copy the entire object.

IMPORTANT this PR manually changes generated files just to prove things can be changed

Signed-off-by: Bogdan Drutu <[email protected]>
@bogdandrutu bogdandrutu requested a review from a team October 23, 2020 19:54
In this experiment, the repeated InstrumentationLibrarySpans field is marked as not nullable:
* There is one important breaking change, after Append is called, changing the object that was used to call Append will not reflect into changes in the appended object (essentially we do a copy).
* IsNil will always return false.
* We can easily and optimal provide now a constructor with capacity, instead of New + Resize.
* Calling Append multiple times is more innefficient than Resize/fill object. Need to copy the entire object.

Signed-off-by: Bogdan Drutu <[email protected]>
@@ -223,17 +223,17 @@ func (ms ResourceSpans) CopyTo(dest ResourceSpans) {
type InstrumentationLibrarySpansSlice struct {
// orig points to the slice otlptrace.InstrumentationLibrarySpans field contained somewhere else.
// We use pointer-to-slice to be able to modify it in functions like Resize.
orig *[]*otlptrace.InstrumentationLibrarySpans
orig *[]otlptrace.InstrumentationLibrarySpans
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are you causing changes in this generated file without changes in pdatagen/ ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually changed to prove that I can pass tests and see how would it look like. As the description says I am not planning to merge this, just as a way to show how this can be done

@yurishkuro
Copy link
Member

fwiw, we also use non-pointers in slices in Jaeger, by configuring gogoproto generation.

@tigrannajaryan
Copy link
Member

Yes, I think eventually we want this, but it would be useful to benchmark to see how much we gain. I think to gain the most we should start with the inner-most objects that are most numerous, e.g. KeyValue pointer slice in the AttributeMap or the StringKeyValue pointer slice in StringMap.

@bogdandrutu
Copy link
Member Author

@tigrannajaryan this is just to show how we can fix the panic issue, and how can we do this for one of the message. But it seems that there is an agreement that this is useful and will indeed start from bottom up.

@pkositsyn
Copy link
Contributor

Just a notice: nil spans also cause panic. @bogdandrutu Maybe it's worth renaming the issue? I think this panic is not really critical now

@bogdandrutu
Copy link
Member Author

@Vemmy124 I know, any nil in any of the slices will cause that.

@tigrannajaryan tigrannajaryan self-assigned this Nov 3, 2020
@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 11, 2020
@github-actions
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Nov 18, 2020
@bogdandrutu bogdandrutu deleted the notnil branch January 13, 2021 18:48
MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this pull request Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants