-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cdc: reduce resolved ts message size (tikv#10666) (tikv#10679)
* cherry pick tikv#10666 to release-5.1 Signed-off-by: ti-srebot <ti-srebot@pingcap.com> * resolve conflicts Signed-off-by: Neil Shen <overvenus@gmail.com> * cdc: fix EventBatcher statistics Signed-off-by: Neil Shen <overvenus@gmail.com> Co-authored-by: Neil Shen <overvenus@gmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
- Loading branch information
1 parent
efca0c6
commit 8af4302
Showing
10 changed files
with
346 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. | ||
|
||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; | ||
use kvproto::cdcpb::ResolvedTs; | ||
use protobuf::Message; | ||
|
||
use cdc::CdcEvent; | ||
|
||
fn bench_cdc_event_size(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("bench_cdc_event_size"); | ||
|
||
// A typical region id. | ||
let region_id = 4194304; | ||
// A typical ts. | ||
let ts = 426624231625982140; | ||
// Benchmark from 1 region id to 131,072 region ids. | ||
for i in 0..18 { | ||
let len = 2usize.pow(i); | ||
let mut resolved_ts = ResolvedTs::default(); | ||
resolved_ts.ts = ts; | ||
resolved_ts.regions = vec![region_id; len]; | ||
|
||
let message_compute_size = resolved_ts.clone(); | ||
group.bench_with_input( | ||
BenchmarkId::new("protobuf::Message::compute_size", len), | ||
&message_compute_size, | ||
|b, message_compute_size| { | ||
b.iter(|| { | ||
black_box(message_compute_size.compute_size()); | ||
}); | ||
}, | ||
); | ||
|
||
let cdc_event_size = CdcEvent::ResolvedTs(resolved_ts); | ||
group.bench_with_input( | ||
BenchmarkId::new("CdcEvent::ResolvedTs::size", len), | ||
&cdc_event_size, | ||
|b, cdc_event_size| { | ||
b.iter(move || { | ||
black_box(cdc_event_size.size()); | ||
}); | ||
}, | ||
); | ||
} | ||
|
||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, bench_cdc_event_size); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.