-
Notifications
You must be signed in to change notification settings - Fork 143
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
More Themis benchmarks #821
Conversation
Put '✅ complete' in the benchmark table.
Wrapped cell means 'Rust wrapper of Secure Cell'
@ilammy could you please take a look? |
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.
Awww, thanks, @G1gg1L3s! ❤️ More benchmarks are always useful and nice to have.
Nicely done, I like it.
It would also be nice to integrate some of these into CI. I believe it's already building all of them, and new Secure Cell benchmarks are already exercised, but you could exercise some Secure Message benchmarks too.
themis/.github/workflows/test-core.yaml
Lines 179 to 188 in 6fc44ce
# This can take a while on the first run, it's better with caches | |
- name: Build benchmarks | |
run: | | |
cd benches/themis | |
cargo bench --no-run | |
# TODO: if building a pull request, compare base with updates | |
- name: Benchmark Secure Cell (master key) | |
run: | | |
cd benches/themis | |
cargo bench -- 'Secure Cell .* master key/4 KB' |
It looks like it's a lot of changes, but if you look closely, you will see that all benches are copypasta with minor changes.
It's not a problem, IMO. Benchmarks aren't changing that often so duplication is okay: makes it easier to tweak individual ones, and avoids wasting enormous amounts of developer time to find a general solution, extract that into a reusable abstraction, etc.
If you run
cargo bench -- --list
, you will see 212 lines of benchmarks, which takes 2-3 lives to run
Well, you're not supposed to run all of them at once. Just the ones you're interested in. Though, I guess it might be helpful to look if there is a way to avoid running all of them if you do cargo bench
.
Secure Message benches use big preallocated buffer [...] but it may affect cache lines.
Not really. Caches keep around the memory that is actually used, not just allocated. Criterion also doesn't do anything special with caches, so given that we're running the same loop over the same buffer, that buffer is very likely to just stay in cache after the first warm-up cycles. Crypto ops are just reading/writing memory sequentially, so they are very cache-friendly.
Naming of rust wrapper benches is under the question.
I'd call the binaries with rust
prefix, as in rust_secure_cell_seal_master_key
, and put something like that to the benchmark group names too, like RustThemis - Secure Cell encryption - Seal, master key
. “Wrapped” is just not descriptive enough, IMO, and can be easily confused for something else.
Also, no more backdoors this time!
I'm still as vigilant as ever.
// Allocate buffer large enough for maximum test | ||
let mut encrypted = vec![0; 10 * MB]; |
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.
FYI: b.iter()
it the hot loop in benchmarks. It's okay to allocate and reallocate outside of that loop. You can, for example, do something like
let message = vec![0; size];
let mut encrypted = vec![0; size + 1024];
The current approach is fine too. (But you do allocate message
every time.)
Also, a trick question: what have you learned by observing the benchmark results and how can you explain them? |
`secure_cell_wrapped -> rust_secure_cell` `Wrapped Secure Cell -> RustThemis - Secure Cell`
Before, CI used the next regexp to filter the benches: "Secure Cell .* passphrase/4 KB". But it matches "Secure Cell..." as well as "RustThemis - Secure Cell...". Replace regexp with an explicit "^Secure Cell...".
Come to think of it, don't we want to put RustThemis benchmarks into
@vixentael, what's your opinion? |
The same as a prevoius one, plus fix some quotation marks formatting issues.
And what I have observed:
|
Agree, let's put RustThemis benchmarks into a separate folder
|
Disregard failing Bitrise test, it's due #823 |
Add entry about rust wrapper benches
I copied |
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.
|
||
## 🦀 RustThemis | ||
|
||
Benchmarks for the Rust wrapper. |
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.
👍
Add the goal of the RustThemis benchmarks. Co-authored-by: vixentael <[email protected]>
Sorry @G1gg1L3s, I see some clippy warnings from CI: https://github.com/cossacklabs/themis/pull/821/checks?check_run_id=2600921096 Can you please fix them? |
Remove some redundant copies
Done! For some reason, I started to see these lints only after upgrading rust toolchain. |
test passed 👏 |
TMAMMHH.
Clippy is a part of toolchain, after all. CI tracks the current |
Failing bitrise test is not but part of this PR, but a temp result of #823 (as bitrise has old carthage). As admin of this repo, I use my sudo 🧙♀️ powers for good and merge this PR. |
This PR introduces new benchmarks for the Themis core and its Rust wrapper.
Before we had only benchmarks for the Secure Cell in seal mode both with Master Key and Passphrase. I've added:
All these benchmarks use the
libthemis_sys
bindings. I also added a couple of Rust wrapper benchmarks:They are located at
benches/themis/benches/secure_cell_wrapped_*
.It looks like it's a lot of changes, but if you look closely, you will see that all benches are copypasta with minor changes.
Although, I'm not sure about some moments:
cargo bench -- --list
, you will see 212 lines of benchmarks, which takes 2-3 lives to run, so maybe some adjustments are needed.Wrapped
word before the name of bench, but maybe there are better ways(?).Also, no more backdoors this time!
Checklist
- [ ] Benchmark results are attached (if applicable)- [ ] Changelog is updated (in case of notable or breaking changes)