Skip to content

Criterion benchmarks#754

Draft
im7mortal wants to merge 43 commits intozip-rs:masterfrom
im7mortal:criterion-benchmarks
Draft

Criterion benchmarks#754
im7mortal wants to merge 43 commits intozip-rs:masterfrom
im7mortal:criterion-benchmarks

Conversation

@im7mortal
Copy link
Copy Markdown
Contributor

#723

Draft of pull request. Check CIs.

this version was created on v3.0.0 originally and later rebased to 1.0.0
chore: Release package zip version 2.0.0

# Conflicts:
#	Cargo.toml
chore: Release package zip version 3.0.0
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
I am not sure about it. We have to have it only for calls which doesn't have calls like `vec.reserve(predicted_write_n);`
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive Criterion-based benchmarks for zip archive operations, including reading, writing, and merging. It adds the criterion and tempfile dev-dependencies and a new benchmark suite in benches/criterion_bench.rs that supports low-memory environments. Feedback was provided to ensure dependency versions in Cargo.toml follow the project's convention of using carets when patch versions are specified.

@im7mortal
Copy link
Copy Markdown
Contributor Author

im7mortal commented Mar 28, 2026

Hi @Its-Just-Nans
I see that fail reason is hardened CI
Screenshot From 2026-03-28 13-09-46

Can you resolve it please? I even didn't touch any CI

AI suggest to edit following step https://github.com/zip-rs/zip2/blob/master/.github/workflows/ci.yaml#L35-L41

@Its-Just-Nans
Copy link
Copy Markdown
Member

Can you resolve it please? I even didn't touch any CI

Criterion cannot compile to big-endian due to half due to zerocopy

@im7mortal
Copy link
Copy Markdown
Contributor Author

I see.

Since Criterion is only a dev-dependency, I assume we don’t need to ensure it builds on a variety of platforms.

The AI suggests setting exactly the targets we need: --lib --bins --tests.

cargo +nightly miri test --lib --bins --tests --target aarch64_be-unknown-linux-gnu --no-default-features

@Its-Just-Nans
Copy link
Copy Markdown
Member

Its-Just-Nans commented Mar 28, 2026

The AI suggests setting exactly the targets we need: --lib --bins --tests.

That could be an option but the MR fixing the issue in zerocopy is merged. If we wait for a bump of zerocopy and half, criterion should compile I think

EDIT: criterion now compiles fine

@Its-Just-Nans
Copy link
Copy Markdown
Member

This MR also close #151 I think

@Its-Just-Nans
Copy link
Copy Markdown
Member

@im7mortal

Why did you use fn seeded_random_bytes(size: usize) instead of the getrandom crate?

Also, can we move it to review ?

@im7mortal
Copy link
Copy Markdown
Contributor Author

@Its-Just-Nans

  1. getrandom is designed so it cannot be deterministic. The function fn seeded_random_bytes(size: usize) always returns the same random sequence. I’ve been wondering whether it’s actually required here. I’ll probably run more tests and then decide. I think I’ll switch back to getrandom later, since the difference is clearly negligible.

  2. I will move the PR to review in mid-April. I am currently running tests on it. My local machine is not suitable for benchmarks, as I have many memory and battery tweaks installed (for example, zram). I switched to testing on my Raspberry Pi 3, which I hadn’t used in 10 years. It’s much more stable there, although I have to spend quite a bit of time setting it up.

I still need to decide on a few things. For example, I haven’t decided whether I should send a preallocated buffer or not. On one hand, you could argue that we are not benchmarking the allocator here. On the other hand, if there is code that performs arbitrary writes, the allocator might expose those issues. There are still other aspects I’m checking.

@im7mortal
Copy link
Copy Markdown
Contributor Author

Just finished another exhausting round of creating benchmarks.

To validate their usability, I set up a clean environment on a sterile Raspberry Pi 3B.

I decided to keep the test data generator in place.

I’m still not sure which is better: the in-memory reader/writer or the file system reader/writer.

On the graph there MAYBE regressions. I will investigate them to prove that the benchmark serves some purpose.

benchmarks1

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