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 decoding of JSON responses. #4019

Merged
merged 5 commits into from
Jul 22, 2021

Conversation

cyriltovena
Copy link
Contributor

Improves frontend allocation by using another json parser for streams.

This also try to use a Bytes() function if available when reading the body to avoid a copy. (This needs to be added to cortex too)

❯ benchcmp  before.txt after.txt8
benchmark                        old ns/op     new ns/op     delta
Benchmark_CodecDecodeLogs-16     9692959       6406357       -33.91%

benchmark                        old allocs     new allocs     delta
Benchmark_CodecDecodeLogs-16     124103         39037          -68.54%

benchmark                        old bytes     new bytes     delta
Benchmark_CodecDecodeLogs-16     6497881       2161604       -66.73%

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

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@cyriltovena cyriltovena marked this pull request as ready for review July 22, 2021 05:08
@cyriltovena cyriltovena requested a review from a team as a code owner July 22, 2021 05:09
@cyriltovena cyriltovena changed the title Improves frontend allocations Improve decoding of JSON responses. Jul 22, 2021
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

Looks great! Left a couple comments.

pkg/loghttp/query.go Outdated Show resolved Hide resolved
pkg/querier/queryrange/codec.go Show resolved Hide resolved
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 work Cyril! Changes LGTM modulo comments by Danny!

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
@cyriltovena cyriltovena merged commit fed9115 into grafana:main Jul 22, 2021
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.

3 participants