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

Improve wal entries encoding. #3153

Merged
merged 1 commit into from
Jan 11, 2021
Merged

Conversation

cyriltovena
Copy link
Contributor

Little trick to avoid memory allocation with regards to bytes slice and string.

benchmp:

❯ benchcmp  before.txt after.txt
benchmark                      old ns/op     new ns/op     delta
Benchmark_EncodeEntries-16     1699362       1055627       -37.88%

benchmark                      old allocs     new allocs     delta
Benchmark_EncodeEntries-16     20025          25             -99.88%

benchmark                      old bytes     new bytes     delta
Benchmark_EncodeEntries-16     5625393       4665376       -17.07%

This originated from an investigation on CPU usage of ingester, see screenshot below:

image

Signed-off-by: Cyril Tovena cyril.tovena@gmail.com

Little trick to avoid memory allocation with regards to bytes slice and string.

benchmp:

```
❯ benchcmp  before.txt after.txt
benchmark                      old ns/op     new ns/op     delta
Benchmark_EncodeEntries-16     1699362       1055627       -37.88%

benchmark                      old allocs     new allocs     delta
Benchmark_EncodeEntries-16     20025          25             -99.88%

benchmark                      old bytes     new bytes     delta
Benchmark_EncodeEntries-16     5625393       4665376       -17.07%
```

This originated from an investigation on CPU usage of ingester.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Copy link
Contributor

@sandeepsukhani sandeepsukhani left a comment

Choose a reason for hiding this comment

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

Nice 🤩
LGTM

Copy link
Collaborator

@kavirajk kavirajk left a comment

Choose a reason for hiding this comment

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

👍 LGTM :)

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

Nice!

@owen-d owen-d merged commit 2a90c4c into grafana:master Jan 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.

None yet

4 participants