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

feat: decode prom requests to grpc #3425

Merged
merged 19 commits into from
Mar 5, 2024

Conversation

v0y4g3r
Copy link
Contributor

@v0y4g3r v0y4g3r commented Mar 4, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

A follow-up in #3478 to improve ~40% more.

What's changed and what's your intention?

This PR decodes WriteRequest in prometheus protocol directly to GreptimeDB's RowInsertRequest to avoid the overhead of conversions.

The benchmark results show that it can reduce 32% deserialization time, hence a 47% improvement in throughput.

test result: ok. 0 passed; 0 failed; 2 ignored; 0 measured; 57 filtered out; finished in 0.00s

     Running benches/bench_prom.rs (target/release/deps/bench_prom-f03f7c5a882a859e)
decode/write_request    time:   [1.7256 ms 1.7287 ms 1.7322 ms]
                        change: [-87.783% -87.722% -87.657%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
  1 (1.00%) high mild
  1 (1.00%) high severe
Benchmarking decode/prom_write_request: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 3.0s. You may wish to increase target time to 6.0s, enable flat sampling, or reduce sample count to 40.
decode/prom_write_request
                        time:   [1.1701 ms 1.1709 ms 1.1717 ms]
                        change: [-86.146% -86.130% -86.114%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild

     Running benches/prom_decode.rs (target/release/deps/prom_decode-6fbb6196f7920b2a)

running 0 tests

This PR does not involves object pooling since it does little to decode performance but brings complexity in object lifecycle management. Memory pooling may help in this case instead.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

@github-actions github-actions bot added the docs-not-required This change does not impact docs. label Mar 4, 2024
@v0y4g3r v0y4g3r force-pushed the feat/decode-prom-requests-to-grpc branch from 7588519 to d631bdf Compare March 4, 2024 08:36
@v0y4g3r v0y4g3r force-pushed the feat/decode-prom-requests-to-grpc branch from d631bdf to 97c99b2 Compare March 4, 2024 09:16
@v0y4g3r v0y4g3r force-pushed the feat/decode-prom-requests-to-grpc branch from 97c99b2 to 36435ae Compare March 4, 2024 09:33
@v0y4g3r v0y4g3r marked this pull request as ready for review March 4, 2024 18:22
@v0y4g3r v0y4g3r requested review from evenyag and waynexia March 4, 2024 18:25
Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Attention: Patch coverage is 60.62874% with 263 lines in your changes are missing coverage. Please review.

Project coverage is 84.49%. Comparing base (ae2c18e) to head (8c0c55b).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3425      +/-   ##
==========================================
- Coverage   85.08%   84.49%   -0.59%     
==========================================
  Files         889      893       +4     
  Lines      146488   146726     +238     
==========================================
- Hits       124632   123978     -654     
- Misses      21856    22748     +892     

@v0y4g3r v0y4g3r force-pushed the feat/decode-prom-requests-to-grpc branch from 706c733 to 53669ea Compare March 5, 2024 06:43
@evenyag evenyag mentioned this pull request Mar 5, 2024
8 tasks
src/frontend/src/instance/prom_store.rs Show resolved Hide resolved
src/servers/src/http/prom_store.rs Show resolved Hide resolved
src/servers/src/prom_row_builder.rs Show resolved Hide resolved
src/servers/src/prom_row_builder.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@evenyag evenyag left a comment

Choose a reason for hiding this comment

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

Most LGTM

src/servers/src/proto.rs Show resolved Hide resolved
src/servers/src/proto.rs Show resolved Hide resolved
src/servers/src/prom_row_builder.rs Outdated Show resolved Hide resolved
src/servers/src/prom_row_builder.rs Show resolved Hide resolved
@v0y4g3r v0y4g3r requested a review from killme2008 March 5, 2024 08:54
@evenyag evenyag enabled auto-merge March 5, 2024 09:09
@evenyag
Copy link
Contributor

evenyag commented Mar 5, 2024

For performance reasons, we expect requests from the remote write protocol to be valid protobuf bytes. The protobuf standard says a string must always contain UTF-8 encoded or 7-bit ASCII text. However, we should provide a strict mode to perform UTF-8 validation or add this validation back once the string validation doesn't hurt the throughput too much.

Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

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

Great work! LGTM

@evenyag evenyag added this pull request to the merge queue Mar 5, 2024
Merged via the queue into GreptimeTeam:main with commit 02b18fb Mar 5, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants