Closed Lonami closed 3 years ago
I would ask you to measure things again after #8 will be merged and close this issue if we'll become OK enough.
pip install cryptg
(0.2 from PyPi):
Doing 1 iteration(s) with 512.0 KB of data for ed_pyaes
Encrypt took 1.37s (avg 1.37s)
Decrypt took 1.44s (avg 1.44s)
Doing 100 iteration(s) with 512.0 KB of data for ed_cryptg
Encrypt took 12.05s (avg 0.12s)
Decrypt took 12.09s (avg 0.12s)
Doing 100 iteration(s) with 512.0 KB of data for ed_tgcrypto
Encrypt took 0.22s (avg 0.00s)
Decrypt took 0.21s (avg 0.00s)
Doing 20 iteration(s) with 512.0 KB of data for ed_ssl
Encrypt took 1.03s (avg 0.05s)
Decrypt took 1.03s (avg 0.05s)
pip install .
(this branch):
Doing 100 iteration(s) with 512.0 KB of data for ed_cryptg
Encrypt took 11.59s (avg 0.12s)
Decrypt took 11.68s (avg 0.12s)
Honestly this makes zero sense. If I run cargo bench
on grammers-crypto
, the story is very different:
This is nowhere near the Python throughput:
>>> size = 100 * 512
>>> print('encrypt', size / 11.59, 'kb/s')
encrypt 4417.601380500431 kb/s
>>> print('decrypt', size / 11.68, 'kb/s')
decrypt 4383.561643835616 kb/s
What? I could expect a small hit from allocations and type conversions Rust-Python, but with only 100 iterations, the fact it's like 8 times slower makes no sense.
(Note there's also https://github.com/Wirtos/libaesni which is using assembly).
Okay I don't know why pip install -e .
is installing an unoptimized build because according to:
By default,
develop
will create a debug build, whileinstall
will create a release build.
But anyway, adding the following to the Cargo.toml
:
[profile.dev]
opt-level = 3
Yields:
Doing 100 iteration(s) with 512.0 KB of data for ed_cryptg
Encrypt took 0.18s (avg 0.00s)
Decrypt took 0.16s (avg 0.00s)
Success I guess.
Closed by #8.
I made a benchmark with the following results:
And from faster to slower, we have:
tgcrypto
cryptg
openssl
pyaes
So, a different implementation may be worth it. Perhaps we can pull-request AES-IGE to
rustls
and use that.See also the conversation that inspired this issue.