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

Add a benchmark utility? #1173

Closed
Mygod opened this issue Feb 2, 2017 · 20 comments
Closed

Add a benchmark utility? #1173

Mygod opened this issue Feb 2, 2017 · 20 comments

Comments

@Mygod
Copy link

Mygod commented Feb 2, 2017

A benchmark utility could be useful for a user to pick the most appropriate cipher on their machine instruction set.

See also: https://tls.mbed.org/api/benchmark_8c_source.html

@enihcam
Copy link

enihcam commented Feb 2, 2017

+1

1 similar comment
@debiansid
Copy link

+1

@flipphos
Copy link

flipphos commented Feb 2, 2017 via email

@riobard
Copy link

riobard commented Feb 2, 2017

Unnecessary. The choice is fairly simple: if the device supports AES-NI, go for AES-GCM. Otherwise Chacha20-Poly1305.

@LexterS999
Copy link

LexterS999 commented Feb 2, 2017

@riobard I'm using this client https://github.com/shadowsocks/shadowsocks-windows/releases on my PC. And there is absent Chacha20-Poly1305 so can i use chacha20 on my client side and use Chacha20-Poly1305 on server side? Is it compatible?

@madeye
Copy link

madeye commented Feb 3, 2017

@Mygod
Copy link
Author

Mygod commented Feb 3, 2017

@madeye Default number for iperf is 8KB which is too small. Try this one?
https://gist.github.com/Mygod/5dc04215b1b4d67ee18597e49379e72a

@Mygod
Copy link
Author

Mygod commented Feb 3, 2017

@riobard Well despite having hardware acceleration, AES-GCM performs at least 40% slower (lower throughput) than chacha20-ietf-poly1305 even on machines with AES-NI. P.S. I've tested on a modern PC with AES-NI, a relatively old one without, a cheap VPS with AES-NI. I'm trying to test on my Android phone but I haven't found an iperf binary yet.

@madeye Perhaps add this script to the main repo?

@LexterS999
Copy link

I'm always using chacha20 on kvm vps with average cpu/mem power and it's good when only you take that. But if you wanna spread then your vps power must to be higher and then you must to use benchmark.

@riobard
Copy link

riobard commented Feb 3, 2017

@asmadeus08 chacha20 as in the old client is a stream cipher. Chacha20-Poly1305 is an AEAD. Completely different beasts.

@Mygod Good to know! I'll try to implement Chacha20-Poly1305 on my Go implementation and see how it flies :)

@Mygod
Copy link
Author

Mygod commented Feb 3, 2017

@asmadeus08 @riobard Here's the benchmark details on my end which also includes traditional stream cipher. As you can see chacha20-ietf-poly1305 is actually comparable to aes-256-ctr.

image

@LexterS999
Copy link

@Mygod the same to me. Chacha20 and chacha20-iеtf is the best choice.
@riobard so i cant use chacha20-poly1305 on my pc client cause there is absent option to chosse that. But i saw request to add those new ciphers on shadowsocks pc client.

@riobard
Copy link

riobard commented Feb 3, 2017

@asmadeus08 AEAD is still work-in-progress. Please wait for official release.

@LexterS999
Copy link

@riobard you mean work-in-progress for this one https://github.com/shadowsocks/shadowsocks-windows/releases ?

@riobard
Copy link

riobard commented Feb 3, 2017

@asmadeus08 I don't think there's AEAD support from anything other than pre-release shadowsocks-libev now. Please wait until the design is fixed.

@LexterS999
Copy link

@riobard Ok, cool. I think they will add it soon too.

@madeye
Copy link

madeye commented Feb 3, 2017

Added via 95ef3d5.

@Mygod Mygod closed this as completed Feb 3, 2017
@Mygod
Copy link
Author

Mygod commented Feb 4, 2017

@riobard I took another look at libsodium's source code and it turns out chacha20 is actually using SSSE3 instructions on supported devices under the hood.

EDIT: And SSSE3 is ~2 years older than AES-NI, even my old computer supports this technology.

@riobard
Copy link

riobard commented Feb 4, 2017

@Mygod Yes. Go's chacha20-poly1305 also got SSE treatment on amd64 (see https://go-review.googlesource.com/#/c/24717/). However Go's chacha20 is not accelerated.

I added chacha20-poly1305 to my Go port and measured using iperf3 (simultaneous encrypting/decrypting). Here's the result on my device (Ivy Bridge Core i7 2.6GHz)

AES-128-GCM       4.57 Gbps
AES-256-GCM       4.35 Gbps
chacha20-poly1305 3.77 Gbps

@enihcam
Copy link

enihcam commented Feb 6, 2017

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

No branches or pull requests

7 participants