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

[chore][pkg/resourcetotelemetry] reduce memory usage by call ensure capacity #29430

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

philchia
Copy link
Contributor

Description:

  1. Reduce memory usage by ensure capacity before merge two maps

Link to tracking Issue:

N/A

Testing:

N/A

Documentation:

N/A

@philchia philchia requested review from mx-psi and a team as code owners November 21, 2023 07:31
Copy link

linux-foundation-easycla bot commented Nov 21, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: philchia / name: Phil (546addd)

@philchia
Copy link
Contributor Author

philchia commented Nov 21, 2023

Here is the benchmark result:

Before:

$ go test -bench=. -benchmem
goos: darwin
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkJoinAttributes/merge_10_into_10-12               341402              3347 ns/op            1628 B/op         34 allocs/op
BenchmarkJoinAttributes/merge_10_into_20-12               180139              7004 ns/op            3229 B/op         64 allocs/op
BenchmarkJoinAttributes/merge_20_into_10-12               268239              4496 ns/op            2909 B/op         35 allocs/op
BenchmarkJoinAttributes/merge_30_into_10-12               198063              5812 ns/op            2909 B/op         35 allocs/op
BenchmarkJoinAttributes/merge_10_into_30-12               115959             10164 ns/op            5022 B/op         94 allocs/op
PASS
ok      github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry       7.237s

After:

$ go test -bench=. -benchmem
goos: darwin
goarch: amd64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkJoinAttributes/merge_10_into_10-12               340310              3304 ns/op            1628 B/op         34 allocs/op
BenchmarkJoinAttributes/merge_10_into_20-12               186794              6491 ns/op            2973 B/op         64 allocs/op
BenchmarkJoinAttributes/merge_20_into_10-12               276632              4272 ns/op            2013 B/op         34 allocs/op
BenchmarkJoinAttributes/merge_30_into_10-12               213165              5562 ns/op            2269 B/op         34 allocs/op
BenchmarkJoinAttributes/merge_10_into_30-12               119604             10185 ns/op            4254 B/op         94 allocs/op
PASS
ok      github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry       7.138s
(base) 

@mx-psi mx-psi merged commit ce88bd3 into open-telemetry:main Nov 21, 2023
83 checks passed
@github-actions github-actions bot added this to the next release milestone Nov 21, 2023
RoryCrispin pushed a commit to ClickHouse/opentelemetry-collector-contrib that referenced this pull request Nov 24, 2023
…apacity (open-telemetry#29430)

Description:

1. Reduce memory usage by ensure capacity before merge two maps

Link to tracking Issue:

N/A

Testing:

N/A

Documentation:

N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants