-
Notifications
You must be signed in to change notification settings - Fork 42
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
Remove buf redux #2179
Open
kruss
wants to merge
2
commits into
esrlabs:master
Choose a base branch
from
kruss:remove_buf_redux
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Remove buf redux #2179
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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,19 @@ | ||
[package] | ||
name = "bufread" | ||
version = "0.1.1" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
|
||
[dev-dependencies] | ||
criterion.workspace = true | ||
proptest.workspace = true | ||
rand.workspace = true | ||
|
||
[[bench]] | ||
name = "buffer_benches" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "reader_benches" | ||
harness = false |
This file contains 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,2 @@ | ||
# bufread | ||
A buffered reader implementation in Rust with special behavior. | ||
23 changes: 23 additions & 0 deletions
23
application/apps/indexer/addons/bufread/benches/bench_config.rs
This file contains 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,23 @@ | ||
// Copyright (c) 2025 ESR Labs GmbH. All rights reserved. | ||
// | ||
// NOTICE: All information contained herein is, and remains | ||
// the property of E.S.R.Labs and its suppliers, if any. | ||
// The intellectual and technical concepts contained herein are | ||
// proprietary to E.S.R.Labs and its suppliers and may be covered | ||
// by German and Foreign Patents, patents in process, and are protected | ||
// by trade secret or copyright law. | ||
// Dissemination of this information or reproduction of this material | ||
// is strictly forbidden unless prior written permission is obtained | ||
// from E.S.R.Labs. | ||
|
||
use criterion::Criterion; | ||
use std::time::Duration; | ||
|
||
pub fn bench_config(sample_size: usize) -> Criterion { | ||
Criterion::default() | ||
.warm_up_time(Duration::from_secs(5)) | ||
.measurement_time(Duration::from_secs(10)) | ||
.sample_size(sample_size) | ||
.significance_level(0.01) | ||
.noise_threshold(0.05) | ||
} |
62 changes: 62 additions & 0 deletions
62
application/apps/indexer/addons/bufread/benches/buffer_benches.rs
This file contains 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,62 @@ | ||
// Copyright (c) 2025 ESR Labs GmbH. All rights reserved. | ||
// | ||
// NOTICE: All information contained herein is, and remains | ||
// the property of E.S.R.Labs and its suppliers, if any. | ||
// The intellectual and technical concepts contained herein are | ||
// proprietary to E.S.R.Labs and its suppliers and may be covered | ||
// by German and Foreign Patents, patents in process, and are protected | ||
// by trade secret or copyright law. | ||
// Dissemination of this information or reproduction of this material | ||
// is strictly forbidden unless prior written permission is obtained | ||
// from E.S.R.Labs. | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use std::hint::black_box; | ||
|
||
#[path = "./bench_config.rs"] | ||
mod bench_config; | ||
use bench_config::bench_config; | ||
|
||
use bufread::DeqBuffer; | ||
|
||
fn write_buffer(buffer: &mut DeqBuffer, src: &[u8]) { | ||
while buffer.write_available() >= src.len() { | ||
buffer.write_from(src); | ||
} | ||
} | ||
|
||
fn write_buffer_benchmark(c: &mut Criterion) { | ||
let mut buffer = DeqBuffer::new(50 * 1000); | ||
let src: [u8; 100] = [1; 100]; | ||
|
||
c.bench_function("write_buffer", |b| { | ||
b.iter(|| write_buffer(black_box(&mut buffer), black_box(&src))) | ||
}); | ||
} | ||
|
||
fn write_read_buffer(buffer: &mut DeqBuffer, src: &[u8], dst: &mut [u8]) { | ||
while buffer.write_available() >= src.len() { | ||
buffer.write_from(src); | ||
} | ||
while buffer.read_available() != 0 { | ||
buffer.read_to(dst); | ||
} | ||
} | ||
|
||
fn write_read_buffer_benchmark(c: &mut Criterion) { | ||
let mut buffer = DeqBuffer::new(50 * 1000); | ||
let src: [u8; 100] = [1; 100]; | ||
let mut dst: [u8; 100] = [1; 100]; | ||
|
||
c.bench_function("write_read_buffer", |b| { | ||
b.iter(|| write_read_buffer(black_box(&mut buffer), black_box(&src), black_box(&mut dst))) | ||
}); | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
config = bench_config(1000); | ||
targets = write_buffer_benchmark, write_read_buffer_benchmark | ||
} | ||
|
||
criterion_main!(benches); |
46 changes: 46 additions & 0 deletions
46
application/apps/indexer/addons/bufread/benches/reader_benches.rs
This file contains 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,46 @@ | ||
#![allow(dead_code)] | ||
|
||
// Copyright (c) 2025 ESR Labs GmbH. All rights reserved. | ||
// | ||
// NOTICE: All information contained herein is, and remains | ||
// the property of E.S.R.Labs and its suppliers, if any. | ||
// The intellectual and technical concepts contained herein are | ||
// proprietary to E.S.R.Labs and its suppliers and may be covered | ||
// by German and Foreign Patents, patents in process, and are protected | ||
// by trade secret or copyright law. | ||
// Dissemination of this information or reproduction of this material | ||
// is strictly forbidden unless prior written permission is obtained | ||
// from E.S.R.Labs. | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use std::hint::black_box; | ||
|
||
#[path = "./bench_config.rs"] | ||
mod bench_config; | ||
use bench_config::bench_config; | ||
|
||
#[path = "../tests/proto.rs"] | ||
mod proto; | ||
|
||
use bufread::BufReader; | ||
use proto::{Parser, Source, MAX_PACKET_LEN}; | ||
|
||
fn proto_benchmark(c: &mut Criterion) { | ||
let source_min_size = 100 * MAX_PACKET_LEN; | ||
let buffer_max_size = 3 * MAX_PACKET_LEN; | ||
let buffer_min_size = MAX_PACKET_LEN; | ||
Comment on lines
+29
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if having let source_min_size = black_box(100 * MAX_PACKET_LEN);
... |
||
|
||
let source = Source::fixed(source_min_size); | ||
let reader = BufReader::new(buffer_max_size, buffer_min_size, source.data()); | ||
let mut parser = Parser::new(reader); | ||
|
||
c.bench_function("proto", |b| b.iter(|| Parser::run(black_box(&mut parser)))); | ||
} | ||
|
||
criterion_group! { | ||
name = benches; | ||
config = bench_config(1000); | ||
targets = proto_benchmark | ||
} | ||
|
||
criterion_main!(benches); |
Oops, something went wrong.
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.
Do we need to provide more infos in the readme?