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

Comments

Projects
None yet
7 participants
@Mygod

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

This comment has been minimized.

Show comment
Hide comment
@enihcam

enihcam commented Feb 2, 2017

+1

@debiansid

This comment has been minimized.

Show comment
Hide comment
@debiansid

debiansid commented Feb 2, 2017

+1

@flipphos

This comment has been minimized.

Show comment
Hide comment
@flipphos

flipphos Feb 2, 2017

flipphos commented Feb 2, 2017

@riobard

This comment has been minimized.

Show comment
Hide comment
@riobard

riobard Feb 2, 2017

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

riobard commented Feb 2, 2017

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

@asmadeus08

This comment has been minimized.

Show comment
Hide comment
@asmadeus08

asmadeus08 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?

asmadeus08 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

This comment has been minimized.

Show comment
Hide comment
@Mygod

This comment has been minimized.

Show comment
Hide comment
@Mygod

Mygod Feb 3, 2017

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

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

This comment has been minimized.

Show comment
Hide comment
@Mygod

Mygod 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?

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?

@asmadeus08

This comment has been minimized.

Show comment
Hide comment
@asmadeus08

asmadeus08 Feb 3, 2017

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.

asmadeus08 commented Feb 3, 2017

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

This comment has been minimized.

Show comment
Hide comment
@riobard

riobard 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 :)

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

This comment has been minimized.

Show comment
Hide comment
@Mygod

Mygod 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

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

@asmadeus08

This comment has been minimized.

Show comment
Hide comment
@asmadeus08

asmadeus08 Feb 3, 2017

@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.

asmadeus08 commented Feb 3, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@riobard

riobard Feb 3, 2017

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

riobard commented Feb 3, 2017

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

@asmadeus08

This comment has been minimized.

Show comment
Hide comment
@asmadeus08

asmadeus08 commented Feb 3, 2017

@riobard

This comment has been minimized.

Show comment
Hide comment
@riobard

riobard 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.

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.

@asmadeus08

This comment has been minimized.

Show comment
Hide comment
@asmadeus08

asmadeus08 Feb 3, 2017

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

asmadeus08 commented Feb 3, 2017

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

@madeye

This comment has been minimized.

Show comment
Hide comment
@madeye

madeye commented Feb 3, 2017

Added via 95ef3d5.

@Mygod Mygod closed this Feb 3, 2017

@Mygod

This comment has been minimized.

Show comment
Hide comment
@Mygod

Mygod 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.

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

This comment has been minimized.

Show comment
Hide comment
@riobard

riobard 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

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

This comment has been minimized.

Show comment
Hide comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment