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

Signalfx exporter: reduce memory allocations for big batches processing #871

Merged

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Aug 31, 2020

Description:
Enabling batching causes many extra allocations in signalfx exporter. This change reduces allocations of []*sfxpb.DataPoint slices by pre-initializing []*sfxpb.DataPoint slice for the whole batch.

Testing:
Benchmark test on a 1000 metrics batch:

BEFORE:

Running tool: /usr/local/bin/go test -benchmem -run=^$ -bench ^(BenchmarkExporterConsumeData)$
goos: darwin
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter
BenchmarkExporterConsumeData-12           78      14264799 ns/op     6911068 B/op      70208 allocs/op
PASS
ok      github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter 1.896s

AFTER:

Running tool: /usr/local/bin/go test -benchmem -run=^$ -bench ^(BenchmarkExporterConsumeData)$
goos: darwin
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter
BenchmarkExporterConsumeData-12    	      93	  12466935 ns/op	 6429209 B/op	   68854 allocs/op
PASS
ok  	github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter	1.897s

@dmitryax dmitryax requested a review from a team August 31, 2020 04:21
@codecov
Copy link

codecov bot commented Aug 31, 2020

Codecov Report

Merging #871 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #871   +/-   ##
=======================================
  Coverage   88.21%   88.21%           
=======================================
  Files         233      233           
  Lines       12395    12396    +1     
=======================================
+ Hits        10934    10935    +1     
  Misses       1111     1111           
  Partials      350      350           
Flag Coverage Δ
#integration 71.28% <ø> (ø)
#unit 88.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
exporter/signalfxexporter/dpclient.go 93.54% <100.00%> (+0.07%) ⬆️
exporter/signalfxexporter/translation/converter.go 99.41% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41ef9a7...988ea3f. Read the comment docs.

Enabling batching causes many extra allocations in signalfx exporter. This change reduces allocations of []*sfxpb.DataPoint slices by pre-initializing []*sfxpb.DataPoint slice for the whole batch.

Benchmark test on a 1000 metrics batch:

BEFORE:
Running tool: /usr/local/bin/go test -benchmem -run=^$ -bench ^(BenchmarkExporterConsumeData)$
goos: darwin
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter
BenchmarkExporterConsumeData-12           78      14264799 ns/op     6911068 B/op      70208 allocs/op
PASS
ok      github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter 1.896s

AFTER:
Running tool: /usr/local/bin/go test -benchmem -run=^$ -bench ^(BenchmarkExporterConsumeData)$
goos: darwin
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter
BenchmarkExporterConsumeData-12    	      93	  12466935 ns/op	 6429209 B/op	   68854 allocs/op
PASS
ok  	github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter	1.897s
@bogdandrutu bogdandrutu merged commit 524b510 into open-telemetry:master Aug 31, 2020
ljmsc referenced this pull request in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
…871)

Transitive dependency changes sometimes do require a change to go.mod
files as well as go.sum. This is already live in the
opentelemetry-go-contrib repo, and this PR brings it here.
codeboten pushed a commit that referenced this pull request Nov 23, 2022
The trailing_metadata method was added to grpc._server.ServicerContext
in gRPC v1.38.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants