You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/01/08 10:04:53 UTC

(incubator-opendal) branch main updated: feat(core/bench): Add benchmark for concurrent write (#3942)

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 52b6f18584 feat(core/bench): Add benchmark for concurrent write (#3942)
52b6f18584 is described below

commit 52b6f18584e355fecfb3769dfa37eef212109da4
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Mon Jan 8 18:04:49 2024 +0800

    feat(core/bench): Add benchmark for concurrent write (#3942)
---
 core/benches/ops/write.rs | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/core/benches/ops/write.rs b/core/benches/ops/write.rs
index aefce82880..3715ac7dc2 100644
--- a/core/benches/ops/write.rs
+++ b/core/benches/ops/write.rs
@@ -27,6 +27,7 @@ use super::utils::*;
 pub fn bench(c: &mut Criterion) {
     if let Some(op) = init_test_service().unwrap() {
         bench_write_once(c, op.info().scheme().into_static(), op.clone());
+        bench_write_with_concurrent(c, op.info().scheme().into_static(), op.clone());
     }
 }
 
@@ -61,3 +62,31 @@ fn bench_write_once(c: &mut Criterion, name: &str, op: Operator) {
 
     group.finish()
 }
+
+fn bench_write_with_concurrent(c: &mut Criterion, name: &str, op: Operator) {
+    let mut group = c.benchmark_group(format!("service_{name}_write_with_concurrent"));
+
+    let mut rng = thread_rng();
+
+    for concurrent in [1, 2, 4, 8] {
+        let content = gen_bytes(&mut rng, 5 * 1024 * 1024);
+        let path = uuid::Uuid::new_v4().to_string();
+
+        group.throughput(criterion::Throughput::Bytes(16 * 5 * 1024 * 1024));
+        group.bench_with_input(
+            concurrent.to_string(),
+            &(op.clone(), &path, content.clone()),
+            |b, (op, path, content)| {
+                b.to_async(&*TEST_RUNTIME).iter(|| async {
+                    let mut w = op.writer_with(path).concurrent(concurrent).await.unwrap();
+                    for _ in 0..16 {
+                        w.write(content.clone()).await.unwrap();
+                    }
+                    w.close().await.unwrap();
+                })
+            },
+        );
+    }
+
+    group.finish()
+}