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

client: optimize encryption #141

Closed
ernado opened this issue Feb 8, 2021 · 2 comments
Closed

client: optimize encryption #141

ernado opened this issue Feb 8, 2021 · 2 comments
Labels
area: client telegram package issues performance

Comments

@ernado
Copy link
Member

ernado commented Feb 8, 2021

Currently encryption of every message requires allocation, because each message has different encryption key.

We can't reuse AES buffer due to crypto/cipher design.

Related issue in go:
golang/go#39365

@stale
Copy link

stale bot commented Feb 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 9, 2022
@tdakkota
Copy link
Member

I think we're fast enough.

grammers.rs:

test encrypt_b0016  ... bench:         157 ns/iter (+/- 3) = 101 MB/s
test encrypt_b0256  ... bench:         496 ns/iter (+/- 20) = 516 MB/s
test encrypt_b0512  ... bench:         856 ns/iter (+/- 62) = 598 MB/s
test encrypt_b1024  ... bench:       1,636 ns/iter (+/- 6) = 625 MB/s
test encrypt_kb0016 ... bench:      23,062 ns/iter (+/- 425) = 710 MB/s
test encrypt_kb0128 ... bench:     182,503 ns/iter (+/- 5,618) = 718 MB/s
test encrypt_kb0512 ... bench:     748,600 ns/iter (+/- 18,533) = 700 MB/s
gotd:

cpu: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
BenchmarkIGEEncrypt
BenchmarkIGEEncrypt/16b
BenchmarkIGEEncrypt/16b-12           13522802          79.92 ns/op   200.20 MB/s         0 B/op         0 allocs/op
BenchmarkIGEEncrypt/256b
BenchmarkIGEEncrypt/256b-12           3048024         381.1 ns/op   671.66 MB/s         0 B/op         0 allocs/op
BenchmarkIGEEncrypt/512b
BenchmarkIGEEncrypt/512b-12           1725553         691.3 ns/op   740.61 MB/s         0 B/op         0 allocs/op
BenchmarkIGEEncrypt/1024b
BenchmarkIGEEncrypt/1024b-12          1000000        1344 ns/op   761.94 MB/s         0 B/op         0 allocs/op
BenchmarkIGEEncrypt/16384b
BenchmarkIGEEncrypt/16384b-12           57978       20085 ns/op   815.71 MB/s         0 B/op         0 allocs/op
BenchmarkIGEEncrypt/131072b
BenchmarkIGEEncrypt/131072b-12           7404      162335 ns/op   807.42 MB/s         0 B/op         0 allocs/op
BenchmarkIGEEncrypt/524288b
BenchmarkIGEEncrypt/524288b-12           1696      648719 ns/op   808.19 MB/s         0 B/op         0 allocs/op
PASS

@stale stale bot removed the stale label Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: client telegram package issues performance
Projects
None yet
Development

No branches or pull requests

2 participants