diff --git a/Cargo.lock b/Cargo.lock index ee35dcc41b841..f110fec5c16c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4582,28 +4582,6 @@ dependencies = [ "rand", ] -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -8603,16 +8581,6 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" -[[package]] -name = "plotlib" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9462104f987d8d0f6625f0c7764f1c8b890bd1dc8584d8293e031f25c5a0d242" -dependencies = [ - "failure", - "svg", -] - [[package]] name = "plotters" version = "0.3.5" @@ -9996,7 +9964,7 @@ dependencies = [ "nix 0.29.0", "opentelemetry", "parking_lot 0.12.1", - "plotlib", + "plotters", "prometheus", "rand", "risingwave_common", @@ -13529,12 +13497,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" -[[package]] -name = "svg" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3685c82a045a6af0c488f0550b0f52b4c77d2a52b0ca8aba719f9d268fa96965" - [[package]] name = "symbolic-common" version = "12.4.0" @@ -13619,18 +13581,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "sysinfo" version = "0.30.0" diff --git a/src/bench/Cargo.toml b/src/bench/Cargo.toml index 32dcdaa2a5df6..d451ef46ef838 100644 --- a/src/bench/Cargo.toml +++ b/src/bench/Cargo.toml @@ -25,7 +25,11 @@ itertools = { workspace = true } libc = "0.2" opentelemetry = { workspace = true, optional = true } parking_lot = { workspace = true } -plotlib = "0.5.1" +plotters = { version = "0.3.5", default-features = false, features = [ + "svg_backend", + "line_series", + "point_series" +] } prometheus = { version = "0.13", features = ["process"] } rand = { workspace = true } risingwave_common = { workspace = true } diff --git a/src/bench/sink_bench/main.rs b/src/bench/sink_bench/main.rs index 94c0427e51351..0aa70ad00c364 100644 --- a/src/bench/sink_bench/main.rs +++ b/src/bench/sink_bench/main.rs @@ -31,10 +31,12 @@ use futures::stream::select_with_strategy; use futures::{FutureExt, StreamExt, TryStreamExt}; use futures_async_stream::try_stream; use itertools::Itertools; -use plotlib::page::Page; -use plotlib::repr::Plot; -use plotlib::style::{LineJoin, LineStyle}; -use plotlib::view::ContinuousView; +use plotters::backend::SVGBackend; +use plotters::chart::ChartBuilder; +use plotters::drawing::IntoDrawingArea; +use plotters::element::{Circle, EmptyElement}; +use plotters::series::{LineSeries, PointSeries}; +use plotters::style::{IntoFont, RED, WHITE}; use risingwave_common::bitmap::Bitmap; use risingwave_common::catalog::ColumnId; use risingwave_connector::dispatch_sink; @@ -215,34 +217,48 @@ impl ThroughputMetric { println!("p90: {:?} rows/s ", p90); println!("p95: {:?} rows/s ", p95); println!("p99: {:?} rows/s ", p99); - let draw_vec: Vec<(f64, f64)> = throughput_vec + let draw_vec: Vec<(f32, f32)> = throughput_vec .iter() .enumerate() .map(|(index, &value)| { ( - (index as f64) * (THROUGHPUT_METRIC_RECORD_INTERVAL as f64 / 1000_f64), - value as f64, + (index as f32) * (THROUGHPUT_METRIC_RECORD_INTERVAL as f32 / 1000_f32), + value as f32, ) }) .collect(); - let s1: Plot = Plot::new(draw_vec).line_style( - LineStyle::new() - .colour("burlywood") - .linejoin(LineJoin::Round), - ); - - let v = ContinuousView::new() - .add(s1) - .x_range(0.0, BENCH_TIME as f64) - .y_range( - **throughput_vec_sorted.first().unwrap() as f64, - **throughput_vec_sorted.last().unwrap() as f64, + let root = SVGBackend::new("throughput.svg", (640, 480)).into_drawing_area(); + root.fill(&WHITE).unwrap(); + let root = root.margin(10, 10, 10, 10); + let mut chart = ChartBuilder::on(&root) + .caption("Throughput Sink", ("sans-serif", 40).into_font()) + .x_label_area_size(20) + .y_label_area_size(40) + .build_cartesian_2d( + 0.0..BENCH_TIME as f32, + **throughput_vec_sorted.first().unwrap() as f32 + ..**throughput_vec_sorted.last().unwrap() as f32, ) - .x_label("Time (s)") - .y_label("Throughput (rows/s)"); + .unwrap(); - Page::single(&v).save("throughput.svg").unwrap(); + chart + .configure_mesh() + .x_labels(5) + .y_labels(5) + .y_label_formatter(&|x| format!("{:.0}", x)) + .draw() + .unwrap(); + + chart + .draw_series(LineSeries::new(draw_vec.clone(), &RED)) + .unwrap(); + chart + .draw_series(PointSeries::of_element(draw_vec, 5, &RED, &|c, s, st| { + EmptyElement::at(c) + Circle::new((0, 0), s, st.filled()) + })) + .unwrap(); + root.present().unwrap(); println!( "Throughput Sink: {:?}",