-
Notifications
You must be signed in to change notification settings - Fork 706
feat(ss-bench): support calibrating metric parameter #740
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
9612ee8
basic impl
Sunt-ing 3b0f329
basic impl
Sunt-ing 7da67a4
basic impl
Sunt-ing ae5d8bf
clippy
Sunt-ing b011300
clippy
Sunt-ing b1ab5c9
fmt
Sunt-ing 6234e30
fmt
Sunt-ing 2ab0d22
fmt
Sunt-ing 9839c16
a little refactor
Sunt-ing 6320eab
a little refactor
Sunt-ing dfde376
a little refactor
Sunt-ing d88da22
a little refactor
Sunt-ing 29d936f
Merge branch 'main' into sunt_move_to_metric_system2
Sunt-ing 03eecb5
Merge branch 'main' into sunt_move_to_metric_system2
Sunt-ing d70c6fc
impl myHistogram
Sunt-ing f44e6a8
rm duplicated code
Sunt-ing 0f106cc
Merge branch 'main' into sunt_move_to_metric_system2
Sunt-ing e9ab89d
fix bug: wrong init upper_bounds
Sunt-ing de08432
clippy
Sunt-ing db44349
clean code
Sunt-ing 2b72e39
revert
Sunt-ing 646660b
refactor
Sunt-ing c6dd7b5
refactor
Sunt-ing 025c417
refactor
Sunt-ing 4c01041
refactor
Sunt-ing 72c554e
Merge branch 'main' into sunt_move_to_metric_system2
Sunt-ing b1ea3f5
adjust bucket
Sunt-ing bc17e0d
adjust bucket
Sunt-ing 6ea3025
Merge branch 'main' into sunt_move_to_metric_system2
Sunt-ing 4e269a8
rm dead code
Sunt-ing File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,119 @@ | ||
| use prometheus::core::{AtomicU64, Collector, GenericCounter, Metric}; | ||
| use prometheus::Histogram; | ||
| use risingwave_storage::for_all_metrics; | ||
| use risingwave_storage::monitor::DEFAULT_STATE_STORE_STATS; | ||
|
|
||
| use super::my_metrics::MyStateStoreStats; | ||
| use crate::utils::my_metrics::MyHistogram; | ||
|
|
||
| #[derive(Default)] | ||
| pub(crate) struct DisplayStat { | ||
| pub(crate) prev_stat: MyStateStoreStats, | ||
| pub(crate) cur_stat: MyStateStoreStats, | ||
| } | ||
|
|
||
| impl DisplayStat { | ||
| pub(crate) fn update_stat(&mut self) { | ||
| // (Ting Sun) TODO: eliminate this clone | ||
| self.prev_stat = self.cur_stat.clone(); | ||
| self.cur_stat = MyStateStoreStats::from_prom_stats(&**DEFAULT_STATE_STORE_STATS); | ||
| } | ||
|
|
||
| pub(crate) fn display_write_batch(&mut self) { | ||
| let perf = self.display_batch_inner(); | ||
|
|
||
| println!( | ||
| " | ||
| writebatch | ||
| {} | ||
| OPS: {} {} bytes/sec", | ||
| perf.histogram, perf.qps, perf.bytes_pre_sec | ||
| ); | ||
| } | ||
|
|
||
| pub(crate) fn display_delete_random(&mut self) { | ||
| let perf = self.display_batch_inner(); | ||
|
|
||
| println!( | ||
| " | ||
| deleterandom | ||
| {} | ||
| OPS: {} {} bytes/sec", | ||
| perf.histogram, perf.qps, perf.bytes_pre_sec | ||
| ); | ||
| } | ||
|
|
||
| fn display_batch_inner(&mut self) -> PerfMetrics { | ||
| let prev_latency_hist = &self.prev_stat.batch_write_latency; | ||
| let cur_latency_hist = &self.cur_stat.batch_write_latency; | ||
|
|
||
| let time_consume = cur_latency_hist.total_sum - prev_latency_hist.total_sum; | ||
|
|
||
| let ops = { | ||
| let written_batch_num = cur_latency_hist.total_count - prev_latency_hist.total_count; | ||
| written_batch_num as f64 / time_consume | ||
| }; | ||
|
|
||
| let bytes_pre_sec = { | ||
| let prev_histogram = &self.prev_stat.batch_write_size; | ||
| let cur_histogram = &self.cur_stat.batch_write_size; | ||
|
|
||
| let written_bytes = cur_histogram.total_sum - prev_histogram.total_sum; | ||
| written_bytes / time_consume | ||
| }; | ||
|
|
||
| PerfMetrics { | ||
| histogram: MyHistogram::from_diff(prev_latency_hist, cur_latency_hist), | ||
| qps: ops, | ||
| bytes_pre_sec, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub(crate) struct PerfMetrics { | ||
| histogram: MyHistogram, | ||
| qps: f64, | ||
| bytes_pre_sec: f64, | ||
| } | ||
|
|
||
| /// Define extension method `print` used in `print_statistics`. | ||
| trait Print { | ||
| fn print(&self); | ||
| } | ||
|
|
||
| impl Print for GenericCounter<AtomicU64> { | ||
| fn print(&self) { | ||
| let desc = &self.desc()[0].fq_name; | ||
| let counter = self.metric().get_counter().get_value() as u64; | ||
| println!("{desc} COUNT : {counter}"); | ||
| } | ||
| } | ||
|
|
||
| impl Print for Histogram { | ||
| fn print(&self) { | ||
| let desc = &self.desc()[0].fq_name; | ||
|
|
||
| let histogram = MyHistogram::from_prom_hist(self.metric().get_histogram()); | ||
| let p50 = histogram.get_percentile(50.0); | ||
| let p95 = histogram.get_percentile(95.0); | ||
| let p99 = histogram.get_percentile(99.0); | ||
| let p100 = histogram.get_percentile(100.0); | ||
|
|
||
| let sample_count = self.get_sample_count(); | ||
| let sample_sum = self.get_sample_sum(); | ||
|
|
||
| println!("{desc} P50 : {p50} P95 : {p95} P99 : {p99} P100 : {p100} COUNT : {sample_count} SUM : {sample_sum}"); | ||
| } | ||
| } | ||
|
|
||
| macro_rules! print_statistics { | ||
| ($( $name:ident: $type:ty ),* ,) => { | ||
| pub(crate) fn print_statistics(stats: &risingwave_storage::monitor::StateStoreStats) { | ||
| println!("STATISTICS:"); | ||
| // print for all fields | ||
| $( stats.$name.print(); )* | ||
| println!(); | ||
| } | ||
| } | ||
| } | ||
| for_all_metrics! { print_statistics } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| pub(crate) mod display_stat; | ||
| pub(crate) mod latency_stat; | ||
| pub(crate) mod store_statistics; | ||
| pub(crate) mod my_metrics; | ||
| pub(crate) mod workload; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
calibrate_histogram
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.
Would fix this in the following PR