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 2023/11/18 17:31:03 UTC

(incubator-opendal) branch benchmark-s3 updated: Fix test

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

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


The following commit(s) were added to refs/heads/benchmark-s3 by this push:
     new 2daf4e89e Fix test
2daf4e89e is described below

commit 2daf4e89e7a0716935c3ee94c89342945a427bed
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sun Nov 19 01:30:54 2023 +0800

    Fix test
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 core/benches/vs_s3/README.md      | 24 +++++++++++++++---------
 core/benches/vs_s3/src/main.rs    | 15 +++++++++++++++
 core/src/services/http/backend.rs | 22 ++++++++++++++++++++++
 3 files changed, 52 insertions(+), 9 deletions(-)

diff --git a/core/benches/vs_s3/README.md b/core/benches/vs_s3/README.md
index f79c57a62..2a44431a5 100644
--- a/core/benches/vs_s3/README.md
+++ b/core/benches/vs_s3/README.md
@@ -4,7 +4,7 @@ This benchmark compares the performance of OpenDAL with the performance of the `
 
 ## Goal
 
-We expect OpenDAL to match `aws_sdk_s3` in speed: the throughput of OpenDAL should be within a `5%` range of `aws_sdk_s3`.
+We expect OpenDAL to match `aws_sdk_s3` in speed: the throughput of OpenDAL should be within a `10%` range of `aws_sdk_s3`.
 
 ## Usage
 
@@ -15,6 +15,8 @@ Testing read/aws_s3_sdk_collect
 Success
 Testing read/aws_s3_sdk_into_async_read
 Success
+Testing read/aws_s3_sdk_into_async_read_with_size_known
+Success
 Testing read/opendal_s3
 Success
 Testing read/opendal_s3_with_range
@@ -24,17 +26,21 @@ Success
 For bench: `cargo run --release -- --bench`
 
 ```shell
-read/aws_s3_sdk_collect time:   [50.007 ms 50.265 ms 50.527 ms]
-                        thrpt:  [316.66 MiB/s 318.31 MiB/s 319.96 MiB/s]
+read/aws_s3_sdk_collect time:   [47.264 ms 47.378 ms 47.504 ms]
+                        thrpt:  [336.82 MiB/s 337.71 MiB/s 338.53 MiB/s]
 
 read/aws_s3_sdk_into_async_read
-                        time:   [11.308 ms 11.675 ms 12.046 ms]
-                        thrpt:  [1.2971 GiB/s 1.3384 GiB/s 1.3818 GiB/s]
+                        time:   [9.8422 ms 11.607 ms 13.703 ms]
+                        thrpt:  [1.1403 GiB/s 1.3462 GiB/s 1.5876 GiB/s]
+
+read/aws_s3_sdk_into_async_read_with_size_known
+                        time:   [7.9572 ms 8.1055 ms 8.2552 ms]
+                        thrpt:  [1.8927 GiB/s 1.9277 GiB/s 1.9636 GiB/s]
 
-read/opendal_s3         time:   [9.5761 ms 9.8121 ms 10.050 ms]
-                        thrpt:  [1.5548 GiB/s 1.5924 GiB/s 1.6317 GiB/s]
+read/opendal_s3         time:   [8.9068 ms 9.2614 ms 9.6912 ms]
+                        thrpt:  [1.6123 GiB/s 1.6871 GiB/s 1.7543 GiB/s]
 
 read/opendal_s3_with_range
-                        time:   [8.9999 ms 9.2246 ms 9.4526 ms]
-                        thrpt:  [1.6530 GiB/s 1.6938 GiB/s 1.7361 GiB/s]
+                        time:   [8.5459 ms 8.7592 ms 8.9739 ms]
+                        thrpt:  [1.7412 GiB/s 1.7838 GiB/s 1.8284 GiB/s]
 ```
diff --git a/core/benches/vs_s3/src/main.rs b/core/benches/vs_s3/src/main.rs
index f7f5c9726..29e7bf138 100644
--- a/core/benches/vs_s3/src/main.rs
+++ b/core/benches/vs_s3/src/main.rs
@@ -95,6 +95,21 @@ fn bench_read(c: &mut Criterion, op: Operator, s3_client: aws_sdk_s3::Client, bu
             let _ = r.read_to_end(&mut bs).await.unwrap();
         });
     });
+    group.bench_function("aws_s3_sdk_into_async_read_with_size_known", |b| {
+        b.to_async(&*TEST_RUNTIME).iter(|| async {
+            let mut r = s3_client
+                .get_object()
+                .bucket(bucket)
+                .key(&path)
+                .send()
+                .await
+                .unwrap()
+                .body
+                .into_async_read();
+            let mut bs = Vec::with_capacity(16 * 1024 * 1024);
+            let _ = r.read_to_end(&mut bs).await.unwrap();
+        });
+    });
     group.bench_function("opendal_s3", |b| {
         b.to_async(&*TEST_RUNTIME).iter(|| async {
             let _: Vec<u8> = op.read(&path).await.unwrap();
diff --git a/core/src/services/http/backend.rs b/core/src/services/http/backend.rs
index 7e1b8b334..9b1da6f23 100644
--- a/core/src/services/http/backend.rs
+++ b/core/src/services/http/backend.rs
@@ -375,6 +375,11 @@ mod tests {
             )
             .mount(&mock_server)
             .await;
+        Mock::given(method("HEAD"))
+            .and(path("/hello"))
+            .respond_with(ResponseTemplate::new(200).insert_header("content-length", "13"))
+            .mount(&mock_server)
+            .await;
 
         let mut builder = HttpBuilder::default();
         builder.endpoint(&mock_server.uri());
@@ -404,6 +409,12 @@ mod tests {
             )
             .mount(&mock_server)
             .await;
+        Mock::given(method("HEAD"))
+            .and(path("/hello"))
+            .and(basic_auth(username, password))
+            .respond_with(ResponseTemplate::new(200).insert_header("content-length", "13"))
+            .mount(&mock_server)
+            .await;
 
         let mut builder = HttpBuilder::default();
         builder.endpoint(&mock_server.uri());
@@ -434,6 +445,12 @@ mod tests {
             )
             .mount(&mock_server)
             .await;
+        Mock::given(method("HEAD"))
+            .and(path("/hello"))
+            .and(bearer_token(token))
+            .respond_with(ResponseTemplate::new(200).insert_header("content-length", "13"))
+            .mount(&mock_server)
+            .await;
 
         let mut builder = HttpBuilder::default();
         builder.endpoint(&mock_server.uri());
@@ -484,6 +501,11 @@ mod tests {
             )
             .mount(&mock_server)
             .await;
+        Mock::given(method("HEAD"))
+            .and(path("/hello"))
+            .respond_with(ResponseTemplate::new(200).insert_header("content-length", "13"))
+            .mount(&mock_server)
+            .await;
 
         let mut builder = HttpBuilder::default();
         builder.endpoint(&mock_server.uri());