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(bench): Add sink bench tool #14064

Merged
merged 16 commits into from
Jan 16, 2024
Merged

feat(bench): Add sink bench tool #14064

merged 16 commits into from
Jan 16, 2024

Conversation

xxhZs
Copy link
Contributor

@xxhZs xxhZs commented Dec 19, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

resolve #13551

In this pr. We add a sink bench tool, We use datagen create data and write it into our sink. We can use it with

  1. Add schema in schema.yml and add sink option in sink_option.yml
  2. Create table in downstream system
  3. run it
cd src/bench

cargo run --bin sink_bench
-- --sink <sinktype must set it in sink_option.yml. If we don't set it, we will just consume the data and not write to the sink>
--rows-per-second <rows per second>
--split-num <Number of threads generated by datagen>

##################example
cargo run --bin sink_bench -- --sink "Iceberg" --rows-per-second 1000000 --split-num "20"  

We set barrier latency is 1000ms, and throughput is calculated every 500ms, A total of 20s
We run bench in ec2(36cpu), where datagen has a thread count of 20 and sink has a parallelism of 1
The result is(rows/s)

clickhouse : [224120, 241181, 274831, 204391, 244294, 269796, 272795, 271840, 203578, 250401, 122147, 98771, 85333, 98107, 212143, 186920, 138326, 156755, 176411, 210103, 252940, 202347, 232902, 259059, 265179, 252437, 207238, 179505, 225523, 245269, 249904, 251401, 240150, 220302, 234581, 234581, 240000, 176761]

redis: [132326, 132326, 132063, 131801, 131282, 130031, 130810, 130549, 130290, 131023, 130810, 130810, 130810, 130810, 130810, 129007, 130290, 130549, 130810, 130810, 130549, 130810, 130549, 130810, 130549, 128000, 130810, 130549, 130549, 130549, 130810, 130549, 130549, 130549, 130549, 129774, 130290, 130810]

iceberg[321654, 144828, 335353, 232661, 342645, 223926, 378123, 215771, 377370, 221133, 368318, 231016, 363091, 224939, 334533, 265050, 340673, 213179, 380167, 226174, 345421, 248346, 358298, 230688, 352892, 184198, 314135, 176176, 330454, 182991]

iceberg java [82972, 199111, 5446, 232268, 128320, 232268, 130072, 225972, 124971, 231619, 132020, 232079, 130397, 233005, 133394, 235682, 133224, 237093, 135836, 222162, 121752, 227555, 132212, 228918, 131712, 223492, 124909, 221021, 130412, 225880]

mysql: [43157, 12466, 17194, 15807, 16756, 15427, 17388, 17003, 17130, 16286, 15906, 15544, 14138, 14787, 17860, 14961, 13837, 17130, 15544, 16542, 15603, 16031, 16351, 16025, 17035, 14054, 16848, 14707, 17098, 13627, 17355, 15485, 16000, 15114, 14760]

psql [50097, 34646, 39384, 36141, 40804, 34403, 40554, 34452, 39922, 36298, 40394, 36230, 38299, 33541, 39536, 35583, 39536, 35378, 39613, 35583, 39536, 34066, 40156, 36366, 39613, 36000, 40156, 35446, 40314, 34805, 40796, 35438, 38149, 35108, 39309, 33348, 38568]

delta [72192, 103005, 48377, 105650, 92542, 107469, 92724, 109065, 93646, 108636, 93460, 109065, 93275, 109714, 93090, 109714, 92542, 109497, 93275, 108102, 23370, 118236, 85164, 114231, 97138, 113777, 96946, 114231, 98771, 114003, 97330, 114671, 88692, 115580, 96063, 115351]

es [23676, 17066, 20317, 30476, 27203, 28500, 22671, 21914, 20237, 21829, 23953, 28926, 28165, 27358, 25116, 25949, 21787, 28000, 24478, 26450, 22438, 21703, 24159, 24000, 22991, 28332, 27463, 27569, 23111, 26360, 24046, 32572, 29481, 34403, 21093, 33284]

cassandra [111084, 141637, 160827, 150948, 163187, 154719, 153293, 155518, 163187, 145707, 153600, 156775, 155864, 163512, 144564, 159558, 152079, 157385, 164245, 157381, 159425, 146285, 167600, 158162, 161147, 156487, 163512, 158162, 157067, 143161, 154412, 152988, 166603, 153293, 153293, 152380, 161380]

doris [197079, 139086, 181184, 152079, 199506, 140749, 199904, 143968, 200303, 131471, 176222, 160864, 179149, 142483, 163920, 133920, 172356, 141473, 187292, 162594, 182857, 150695, 175776, 159785, 186550, 144790, 189328, 141077, 192633, 157013, 187292, 154467, 165059, 148359, 183952]

starrocks [211301, 108111, 158931, 149205, 182857, 158162, 195047, 138378, 190984, 161410, 182857, 172185, 182134, 150097, 198259, 164630, 194171, 153518, 194661, 146285, 199904, 164252, 182495, 153600, 187665, 174046, 181184, 147252, 197864, 152237, 185625, 165403, 203174, 173188, 174384]

bigquery Throughput Sink: [1921, 2089, 2023, 1950, 2070, 1980, 1780, 2005, 2035, 2019, 2094, 2023, 1939, 1899, 2003, 2106, 1996, 2122, 1996, 2015, 2079, 1865, 2135, 2070]

kafka [66125, 128509, 141940, 156755, 166934, 171688, 165556, 166603, 173041, 168970, 175426, 175177, 172698, 176411, 173732, 169644, 171676, 146285, 146285, 145707, 141029, 147161, 147731, 147161, 146845, 147161, 147731, 142222, 143968, 143400, 145707, 142222, 162862, 161897, 168970, 169644, 167266, 163682]

pulser [84661, 79712, 79081, 84828, 82160, 81269, 81431, 80629, 76598, 80629, 80000, 81108, 76447, 77513, 77696, 83467, 81269, 82160, 79081, 77847, 77359, 82972, 80948, 81443, 78305, 75557, 77847, 83301, 80788, 76901, 77668, 82160, 80948, 82000, 78769, 74729, 77359, 82483]
bigquery with gcp[11715, 11961, 15369, 15114, 12868, 16000, 14813, 14499, 13585, 13575, 14681, 15142, 13864, 15031, 15814, 14760, 14840, 14654, 15515, 15456, 15369, 13679, 15142, 15226, 14602, 14499, 15086, 13945, 16000, 17757, 17162, 14000, 12239, 15633, 16725, 16941]
es after refactor ["27402 rows/s", "24046 rows/s", "32315 rows/s", "38526 rows/s", "35514 rows/s", "45379 rows/s", "43914 rows/s", "46090 rows/s", "52512 rows/s", "49516 rows/s", "49516 rows/s", "52203 rows/s", "53035 rows/s", "52203 rows/s", "54000 rows/s", "52203 rows/s", "51397 rows/s", "53271 rows/s", "54640 rows/s", "52512 rows/s", "46362 rows/s", "50793 rows/s", "49042 rows/s", "44876 rows/s", "49420 rows/s", "51797 rows/s", "47906 rows/s", "50592 rows/s", "49516 rows/s", "52720 rows/s", "49612 rows/s", "50809 rows/s", "52512 rows/s", "53685 rows/s", "48858 rows/s", "53894 rows/s", "55565 rows/s"]
es with flink adapt ["29303 rows/s", "17487 rows/s", "24478 rows/s", "29312 rows/s", "36355 rows/s", "36283 rows/s", "42498 rows/s", "37778 rows/s", "42666 rows/s", "42164 rows/s", "43828 rows/s", "41593 rows/s", "40078 rows/s", "41918 rows/s", "40796 rows/s", "40000 rows/s", "42498 rows/s", "38568 rows/s", "44000 rows/s", "39460 rows/s", "41593 rows/s", "40960 rows/s", "44259 rows/s", "41795 rows/s", "43323 rows/s", "40314 rows/s", "40156 rows/s", "34388 rows/s", "43490 rows/s", "43074 rows/s", "44876 rows/s", "43074 rows/s", "43914 rows/s", "41918 rows/s", "44433 rows/s", "42586 rows/s", "44876 rows/s"]

At the same time we fix a bug in this pr cassandra sink, cassandra api commit each time the number of rows has a maximum value. With higher throughput, can not be simply according to the checkpoint for the commit

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

save

save

save

save

save

add
@xxhZs xxhZs marked this pull request as ready for review December 20, 2023 03:05
@xxhZs xxhZs requested a review from a team as a code owner December 20, 2023 03:05
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

Attention: 321 lines in your changes are missing coverage. Please review.

Comparison is base (feadac7) 67.90% compared to head (232db26) 67.82%.
Report is 3 commits behind head on main.

Files Patch % Lines
src/bench/sink_bench/main.rs 0.00% 239 Missing ⚠️
src/connector/src/sink/coordinate.rs 0.00% 28 Missing ⚠️
src/connector/src/sink/catalog/mod.rs 0.00% 18 Missing ⚠️
src/connector/src/sink/remote.rs 0.00% 15 Missing ⚠️
src/connector/src/sink/iceberg/mod.rs 0.00% 12 Missing ⚠️
src/connector/src/sink/mod.rs 0.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14064      +/-   ##
==========================================
- Coverage   67.90%   67.82%   -0.08%     
==========================================
  Files        1554     1555       +1     
  Lines      268655   268967     +312     
==========================================
- Hits       182417   182416       -1     
- Misses      86238    86551     +313     
Flag Coverage Δ
rust 67.82% <0.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xxhZs xxhZs requested a review from wenym1 December 22, 2023 03:52
@@ -297,6 +297,17 @@ pub trait Sink: TryFrom<SinkParam, Error = SinkError> {

async fn validate(&self) -> Result<()>;
async fn new_log_sinker(&self, writer_param: SinkWriterParam) -> Result<Self::LogSinker>;
#[cfg(feature = "sink_bench")]
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, we introduce this new method because in benchmark we are not able to create a grpc meta client. If so, instead of adding a cargo feature and a new method in the sink trait, we can change the meta_client in SinkWriterParam to an enum that can be either grpc meta client, or our mocked meta client.

The call path of meta client in sink coordination is

let sink_coordinate_client = meta_client.sink_coordinate_client();
let stream_handle = StreamHandle::new(sink_coordinate_client);

only the stream_handle at the end will be stored as a field in some sink writer. The BidiStreamHandle contains only a request channel sender and a box response stream, which can be easily mocked.

Therefore, we can have enum for meta_client and coordinate_client. The meta_client enum has method fn sink_coordinate_client(&self) to create the corresponding sink_coordinate_client enum. The sink_coordinate_client enum has method fn new_stream_handle(self, PbSinkParam, Bitmap) to create the stream handle. The grpc variant of the sink_coordinate_client enum will follow the original call path, while the mock variant will create a mocked bidi stream handle.

Besides, since we only bench the performance of writer, we don't really need to create the coordinator to commit the metadata. When creating the mocked bidi stream handle, we can just spawn a tokio task to receive the commit request and return with a commit response immediately.

In this way, we will not have to have a new cargo feature and introduce so many hacks in the concrete sink implementation.

@@ -122,6 +124,7 @@ private void write_append_only(Iterator<SinkRow> rows) {
.withDescription("Unknown operation: " + op)
.asRuntimeException();
}
tryCommit();
Copy link
Contributor

Choose a reason for hiding this comment

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

This optimization of cassandra sink can be put in a separate PR and we can paste improvement gained from the optimization in the PR description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bug, fixed in this pr by the way, the exact description has been added to the pr description

Copy link
Contributor

@wenym1 wenym1 left a comment

Choose a reason for hiding this comment

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

The benchmark output of the sink in the current PR description is not readable. Can we port to some benchmark framework to better virtualize the output? Such as the criterion framework.

@@ -166,6 +166,31 @@ impl SinkFormatDesc {
}))
}

#[cfg(feature = "sink_bench")]
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose for this mock method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is to be compatible with sink's two syntaxes, and our redis is only support format syntax, so there is no redis in the method, but the mock needs to be converted to format by redis's option, I will move this method to the bench directory.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 4686 files.

Valid Invalid Ignored Fixed
2048 1 2637 0
Click to see the invalid file list
  • src/bench/sink_bench/main.rs

@@ -0,0 +1,426 @@
// Copyright 2023 RisingWave Labs
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2023 RisingWave Labs
// Copyright 2024 RisingWave Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Copyright 2023 RisingWave Labs

fix
@xxhZs xxhZs force-pushed the xxh/bench-sink branch 2 times, most recently from 2374951 to ea658e9 Compare January 4, 2024 06:20
@wenym1
Copy link
Contributor

wenym1 commented Jan 4, 2024

I guess something wrong happened in the rebase. There are many unrelated diff in the files changed.

@xxhZs
Copy link
Contributor Author

xxhZs commented Jan 4, 2024

I guess something wrong happened in the rebase. There are many unrelated diff in the files changed.

Yes, I am working on it

src/connector/src/sink/coordinate.rs Outdated Show resolved Hide resolved
src/connector/src/sink/coordinate.rs Outdated Show resolved Hide resolved
src/connector/src/sink/mod.rs Outdated Show resolved Hide resolved
src/bench/sink_bench/main.rs Outdated Show resolved Hide resolved
src/bench/sink_bench/main.rs Outdated Show resolved Hide resolved
Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

LGTM for Cargo.toml

@xxhZs xxhZs added this pull request to the merge queue Jan 16, 2024
Merged via the queue into main with commit 84c9a08 Jan 16, 2024
27 of 29 checks passed
@xxhZs xxhZs deleted the xxh/bench-sink branch January 16, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bench: Establish a Remote sink benchmark to monitor the embedded connector node performance
3 participants