Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Reduce allocations#1204

Merged
rghetia merged 1 commit intocensus-instrumentation:masterfrom
boekkooi-fresh:patch/reduce-alloc
Apr 3, 2020
Merged

Reduce allocations#1204
rghetia merged 1 commit intocensus-instrumentation:masterfrom
boekkooi-fresh:patch/reduce-alloc

Conversation

@boekkooi-fresh
Copy link
Copy Markdown
Contributor

Hello,
First of thank you for taking the time to view this PR and your work on opencensus!

While trying to find a performance issue on a service I noticed that Span.lruAttributesToAttributeMap was allocating a bit more often then I was expecting.
To reduce the amount of allocation I now provide the length of the source slice/map as the capacity as the new map.slice.

When creating a copy of a slice/map we already know the size/capacity that the target slice/map needs to be.
By using make and providing the capacity argument we avoid allocation memory to grow the slice/map.
@boekkooi-fresh boekkooi-fresh requested review from a team, rakyll and rghetia as code owners March 30, 2020 12:13
@googlebot
Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@boekkooi-fresh
Copy link
Copy Markdown
Contributor Author

@googlebot I signed it!

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@rghetia rghetia merged commit 46dfec7 into census-instrumentation:master Apr 3, 2020
@rghetia
Copy link
Copy Markdown
Contributor

rghetia commented Apr 3, 2020

@boekkooi-fresh thank you for finding the issue and fixing it.

@boekkooi-fresh boekkooi-fresh deleted the patch/reduce-alloc branch April 3, 2020 06:51
@boekkooi-fresh
Copy link
Copy Markdown
Contributor Author

No problem 😄 and thanks for the quick merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants