You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "zjregee (via GitHub)" <gi...@apache.org> on 2024/05/12 12:50:27 UTC
[PR] feat(bench): add buffer benchmark [opendal]
zjregee opened a new pull request, #4603:
URL: https://github.com/apache/opendal/pull/4603
related: #4595
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bench): add buffer benchmark [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #4603:
URL: https://github.com/apache/opendal/pull/4603#discussion_r1599344403
##########
core/benches/types/buffer.rs:
##########
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use bytes::Buf;
+use criterion::Criterion;
+use opendal::Buffer;
+use rand::thread_rng;
+use size::Size;
+
+use super::utils::*;
+
+pub fn bench_contiguous_buffer(c: &mut Criterion) {
Review Comment:
We don't need to bench the contiguous_buffer since it's should be the same with bench `Bytes`.
##########
core/benches/types/buffer.rs:
##########
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use bytes::Buf;
+use criterion::Criterion;
+use opendal::Buffer;
+use rand::thread_rng;
+use size::Size;
+
+use super::utils::*;
+
+pub fn bench_contiguous_buffer(c: &mut Criterion) {
+ let mut group = c.benchmark_group("bench_contiguous_buffer");
+
+ let mut rng = thread_rng();
+
+ for size in [Size::from_kibibytes(256), Size::from_mebibytes(4)] {
+ let bytes_buf = gen_bytes(&mut rng, size.bytes() as usize);
+ let buffer = Buffer::from(bytes_buf.clone());
+
+ let bytes_buf_name = format!("bytes buf {}", size.to_string());
+ let buffer_name = format!("contiguous buffer {}", size.to_string());
+
+ group.bench_function(format!("{} {}", bytes_buf_name, "chunk"), |b| {
+ b.iter(|| bytes_buf.chunk())
+ });
+ group.bench_function(format!("{} {}", buffer_name, "chunk"), |b| {
+ b.iter(|| buffer.chunk())
+ });
+
+ group.bench_function(format!("{} {}", bytes_buf_name, "advance"), |b| {
+ b.iter(|| {
+ let mut bytes_buf = bytes_buf.clone();
+ bytes_buf.advance((size.bytes() as f64 * 0.5) as usize);
+ })
+ });
+ group.bench_function(format!("{} {}", buffer_name, "advance"), |b| {
+ b.iter(|| {
+ let mut buffer = buffer.clone();
+ // Advance non-integer number of Bytes.
+ buffer.advance((size.bytes() as f64 * 0.5) as usize);
+ })
+ });
+ }
+
+ group.finish()
+}
+
+pub fn bench_non_contiguous_buffer(c: &mut Criterion) {
Review Comment:
For non_contiguous_buffer, I want to know the perf some extream cases.
For example
- how long it's take to build a Buffer from a very large iterator, like 1k, 10k, 100k, 1m? (we can just use the same `Bytes` to reduce the memory usage)
- how long it's take for `Buffer` to advance, truncate on a large `Buffer`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bench): add buffer benchmark [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #4603:
URL: https://github.com/apache/opendal/pull/4603
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org