-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 JSON parser and add labels parser hints. #3080
Conversation
This is a rework of the json parser, that now uses iteration over reflection allowing to avoid allocations. I've also implemented a way to guess and hints what labels needs to be parsed when doing metric queries, this means we can extract only the few labels required from the log line. benchcmp ``` ❯ benchcmp before.txt after.txt5 benchmark old ns/op new ns/op delta Benchmark_Parser/json/no_labels_hints-16 9889 3281 -66.82% Benchmark_Parser/logfmt/no_labels_hints-16 1624 1671 +2.89% Benchmark_Parser/logfmt/labels_hints-16 1601 790 -50.66% benchmark old allocs new allocs delta Benchmark_Parser/json/no_labels_hints-16 139 56 -59.71% Benchmark_Parser/logfmt/no_labels_hints-16 31 31 +0.00% Benchmark_Parser/logfmt/labels_hints-16 31 5 -83.87% benchmark old bytes new bytes delta Benchmark_Parser/json/no_labels_hints-16 3671 912 -75.16% Benchmark_Parser/logfmt/no_labels_hints-16 464 464 +0.00% Benchmark_Parser/logfmt/labels_hints-16 464 144 -68.97% ``` I've experienced a 2x to 4x improvement in my cluster. Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, but I really like these optimizations.
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #3080 +/- ##
==========================================
+ Coverage 62.88% 62.91% +0.03%
==========================================
Files 186 187 +1
Lines 15949 16089 +140
==========================================
+ Hits 10030 10123 +93
- Misses 4987 5029 +42
- Partials 932 937 +5
|
…fana#3080) Signed-off-by: Marco Pracucci <marco@pracucci.com>
This is a rework of the json parser, that now uses iteration over reflection allowing to avoid allocations.
I've also implemented a way to guess and hints what labels needs to be parsed when doing metric queries, this means we can extract only the few labels required from the log line.
benchcmp
I've experienced a 2x to 4x improvement in my cluster.
Signed-off-by: Cyril Tovena cyril.tovena@gmail.com