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

[Exporter.Geneva] Avoid allocation when serializing scopes #433

Conversation

utpilla
Copy link
Contributor

@utpilla utpilla commented Jun 17, 2022

Fixes #391

Changes

  • Avoid allocation of closure object when serializing scopes

@utpilla utpilla added the comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva label Jun 17, 2022
@codecov
Copy link

codecov bot commented Jun 17, 2022

Codecov Report

Merging #433 (8407af7) into main (d6d951c) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@          Coverage Diff           @@
##            main    #433    +/-   ##
======================================
  Coverage   0.00%   0.00%            
======================================
  Files        163     167     +4     
  Lines       4983    5403   +420     
======================================
- Misses      4983    5403   +420     
Impacted Files Coverage Δ
...OpenTelemetry.Exporter.Geneva/GenevaLogExporter.cs 0.00% <0.00%> (ø)
...enTelemetry.Exporter.Geneva/GenevaTraceExporter.cs 0.00% <0.00%> (ø)
...nTelemetry.Exporter.Geneva/GenevaMetricExporter.cs 0.00% <0.00%> (ø)
...ation/HangfireInstrumentationJobFilterAttribute.cs 0.00% <0.00%> (ø)
...on.EventCounters/MeterProviderBuilderExtensions.cs 0.00% <0.00%> (ø)
...tation.EventCounters/EventCounterMetricsOptions.cs 0.00% <0.00%> (ø)
...ounters/EventCountersInstrumentationEventSource.cs 0.00% <0.00%> (ø)
...trumentation.EventCounters/EventCounterListener.cs 0.00% <0.00%> (ø)

@utpilla utpilla marked this pull request as ready for review June 17, 2022 23:05
@utpilla utpilla requested a review from a team June 17, 2022 23:05
@utpilla utpilla changed the title [Exporter.Geneva] Code changes to avoid allocation when serializing scopes [Exporter.Geneva] Avoid allocation when serializing scopes Jun 17, 2022
internal ushort ScopeDepth;
internal int IndexForArrayLength;
internal int Cursor;
internal byte[] Buffer;
Copy link
Member

Choose a reason for hiding this comment

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

If you made this...

    internal byte[] Buffer = new byte[BUFFER_SIZE];

You could probably get rid of...

private static readonly ThreadLocal<byte[]> m_buffer = new ThreadLocal<byte[]>(() => null);

...and just use exporterState for everything the exporter needs on a thread.

Copy link
Member

@CodeBlanch CodeBlanch left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot requested a review from CodeBlanch June 21, 2022 00:36
{
state.Cursor = MessagePackSerializer.SerializeAsciiString(state.Buffer, state.Cursor, "scopes");
state.Cursor = MessagePackSerializer.WriteArrayHeader(state.Buffer, state.Cursor, ushort.MaxValue);
state.IndexForArrayLength = state.Cursor - 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

If this line is moved up one then the - 2 is not needed right?

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2022

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 Jul 6, 2022
@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 Jul 14, 2022
@utpilla utpilla reopened this Jul 14, 2022
@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 Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Exporter.Geneva] Avoid allocation while exporting ILogger scopes
6 participants