Skip to content

Add bufreader example#131

Merged
nyonson merged 1 commit intorust-bitcoin:mainfrom
nyonson:bench-io
Jul 11, 2025
Merged

Add bufreader example#131
nyonson merged 1 commit intorust-bitcoin:mainfrom
nyonson:bench-io

Conversation

@nyonson
Copy link
Collaborator

@nyonson nyonson commented Jul 11, 2025

Trying to capture just how effective a bufreader is for the BIP-324 protocol. I think this shows that it is usually going to help, probably never hurt.

How it generally looks on my machine:

> cargo run --release --example bufreader --features tokio
    Finished `release` profile [optimized] target(s) in 0.05s
     Running `target/release/examples/bufreader`
Bitcoin Traffic: 100000 total messages, 9940000 bytes
  Without BufReader: 126 ms
  With BufReader:    98 ms
  Improvement:       22.1%
Large Messages: 3000 total messages, 90112000 bytes
  Without BufReader: 234 ms
  With BufReader:    233 ms
  Improvement:       0.1%
Small Messages: 100000 total messages, 300000 bytes
  Without BufReader: 101 ms
  With BufReader:    72 ms
  Improvement:       28.2%

Trying to capture just how effective a bufreader is for the BIP-324
protocol. I think this shows that it is usually going to help, probably
never hurt.
@nyonson nyonson merged commit 6df3b18 into rust-bitcoin:main Jul 11, 2025
10 checks passed
@rustaceanrob
Copy link
Collaborator

Is this all local data? Could be useful to see how this looks over traffic with latency in the future. Conceptually makes sense.

@nyonson
Copy link
Collaborator Author

nyonson commented Jul 12, 2025

Is this all local data? Could be useful to see how this looks over traffic with latency in the future. Conceptually makes sense.

Yea, kinda hard to measure with so many variables, but this is the "best case" scenario for the buffer where there are a lot of packets sittin in the network socket. I would guess the benefit of the buffer only goes down from here. I'll try to model a more realistic network scenario though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants