Skip to content
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

core/benches: Add benchmark for apply_inbound #95

Conversation

mxinden
Copy link

@mxinden mxinden commented Dec 1, 2022

This commit adds a small benchmark test for the apply_inbound method. This allows benchmarking the usage of Vec or SmallVec in the InboundUpgradeApplyState state machine.

The benchmark executes a minimal multistream-select listener upgrade on an in-memory connection and then runs the Ready upgrade on top of the negotiated in-memory connection. The protocol negotiated in the first step is either stored in a Vec or a SmallVec.

I am unable to optimize the benchmark such that SmallVec has a significant performance benefit over Vec. I would love to be proven wrong, i.e. I would love for someone to find a benchmark that does show a significant difference.

You can replicate these results by running:

cd core
cargo bench --bench upgrade -- --save-baseline vec

cargo bench --bench upgrade -- --save-baseline small-vec

➜  critcmp small-vec vec
group              small-vec                              vec
-----              ---------                              ---
inbound_upgrade    1.00    342.6±1.43ns        ? ?/sec    1.02    348.0±1.66ns        ? ?/sec

(Note on the protocol name, I was initially testing the failure case.)

This commit adds a small benchmark test for the `apply_inbound` method. This allows benchmarking the
usage of `Vec` or `SmallVec` in the `InboundUpgradeApplyState` state machine.

The benchmark executes a minimal multistream-select listener upgrade on an in-memory connection and
then runs the `Ready` upgrade on top of the negotiated in-memory connection. The protocol negotiated
in the first step is either stored in a `Vec` or a `SmallVec`.

I am unable to optimize the benchmark such that `SmallVec` has a significant performance benefit
over `Vec`. I would love to be proven wrong, i.e. I would love for someone to find a benchmark that
does show a significant difference.

You can replicate these results by running:

```
cd core
cargo bench --bench upgrade -- --save-baseline vec

cargo bench --bench upgrade -- --save-baseline small-vec

➜  critcmp small-vec vec
group              small-vec                              vec
-----              ---------                              ---
inbound_upgrade    1.00    342.6±1.43ns        ? ?/sec    1.02    348.0±1.66ns        ? ?/sec
```

(Note on the protocol name, I was initially testing the failure case.)
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.

1 participant