-
Notifications
You must be signed in to change notification settings - Fork 9.8k
textparse: Optimized protobuf parser with custom streaming unmarshal. #15731
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
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
78e9d70
to
1b22fd0
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Getting back to this after holidays... |
192d376
to
8333f3c
Compare
91697a5
to
308d630
Compare
This should be now good to go 🎉 cc @krajorama @beorn7 @bboreham Results looks solid. There's room for further allocation improvements, but I propose we iterate. Some of those needs interface updates.
|
I have some ideas to optimize further (see https://pprof.me/14c6981f2f1f0ab8dce893729df1da67/?profileType=profile%253Aalloc_objects%253Acount%253Aspace%253Abytes&color_by=filename), but I will do those in the next iteration - this PR is already big. |
/prombench help |
Available Commands:
Advanced Flags for
Examples:
|
/prombench main --bench.version=bench/protofirst |
⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️ Compared versions: Custom benchmark version: After the successful deployment (check status here), the benchmarking results can be viewed at: Available Commands:
|
/prombench cancel |
Benchmark cancel is in progress. |
/prombench cancel |
/prombench main --bench.version=bench/cross-feature/protofirst |
⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️ Compared versions: Custom benchmark version: After the successful deployment (check status here), the benchmarking results can be viewed at: Available Commands:
|
Depends on #15731 Signed-off-by: bwplotka <bwplotka@gmail.com>
Depends on #15731 Signed-off-by: bwplotka <bwplotka@gmail.com>
Depends on #15731 Signed-off-by: bwplotka <bwplotka@gmail.com>
Depends on #15731 Signed-off-by: bwplotka <bwplotka@gmail.com>
Depends on #15731 Signed-off-by: bwplotka <bwplotka@gmail.com>
SummaryThe current state: Microbenchmarks from #15731 (comment) are still valid.Protobuf parsing is:
Macrobenchmarks from #15731 (comment) and #15731 (comment)
Next stepsI propose we cache more in #16020 (more complex, this PR can be merged safely without #16020 ) |
/prombench cancel |
Benchmark cancel is in progress. |
…(...) (#16012) * model/textparse: Change parser interface Metric(...) string to Labels(...) Simplified the interface given no one is using the return argument. Renamed for clarity too. Found and discussed #15731 (comment) Signed-off-by: bwplotka <bwplotka@gmail.com> * Fixed comments; optimized not needed copy for om and text. Signed-off-by: bwplotka <bwplotka@gmail.com> --------- Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: bwplotka <bwplotka@gmail.com> Update model/textparse/protobufparse.go Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com> Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com> Addressing comments. Signed-off-by: bwplotka <bwplotka@gmail.com> decoder: reuse histograms and summaries. Signed-off-by: bwplotka <bwplotka@gmail.com> optimize help returning (5% of mem utilization). Signed-off-by: bwplotka <bwplotka@gmail.com> Apply suggestions from code review Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com> Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com> Update prompb/io/prometheus/client/decoder.go Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com> Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com> Fix build. Signed-off-by: bwplotka <bwplotka@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.
Let’s give it a go.
…(...) (prometheus#16012) * model/textparse: Change parser interface Metric(...) string to Labels(...) Simplified the interface given no one is using the return argument. Renamed for clarity too. Found and discussed prometheus#15731 (comment) Signed-off-by: bwplotka <bwplotka@gmail.com> * Fixed comments; optimized not needed copy for om and text. Signed-off-by: bwplotka <bwplotka@gmail.com> --------- Signed-off-by: bwplotka <bwplotka@gmail.com>
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
/prombench main --bench.version=bench/protofirst |
⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️ Compared versions: Custom benchmark version: After the successful deployment (check status here), the benchmarking results can be viewed at: Available Commands:
|
Fixes #14668
Depends on #15966
Previous attempts #15726 #15729
Design
We have opportunity to stream protobuf unmarshalling. It's already sort of streamed by metric family, however no memory is reused across families. With this new implementation we:
MetricSteamingDecoder
that allows progressing per MetricFamily. It reuses previous MetricFamily object (e.g. internal bytes for lazy decoding of metrics).Maintenance
While it looks cumbersome to maintain, to make things efficient, one way or another we have to have streaming/lazy decoding with reusing of as much as possible. This does not depend on gogo we can do this on OpaqueAPI too but didn't want to change too much here. We could try to work with vtprotobuf or write our own plugin for those methods, but we can start by handcrafting now, this proto is not changing at all (if it will change in future, it will be OpenMetric proto likely).