Here is a good news.

The crypto/des package has some low-hanging-fruit optimizations that are 
worth trying.

The results of the benchmark have being improved to an extent (I tested it 
on AMD64 though):

> Old

BenchmarkEncrypt-4       2000000               852 ns/op           9.38 MB/s

BenchmarkDecrypt-4       2000000               896 ns/op           8.92 MB/s


> New

BenchmarkEncrypt-4       3000000               536 ns/op          14.90 MB/s

BenchmarkDecrypt-4       3000000               539 ns/op          14.82 MB/s


Besides unrolling the loop in the feistel function and adding bounds-check 
hints, I made a change to the the arrangement of the sbox matrix to 
eliminate the redundant calculations of rows and columns in the feistel 
function, which fortunately does not make the code uglier. The idea is to 
move the cost from the hot spot to the run-once initialization function 
whenever possible.


Hopefully there are other places that can be speeded up without messing up 
the code.

On Sunday, August 28, 2016 at 12:43:23 AM UTC+8, mura wrote:
>
> Hi gophers,
>
> We have some legacy systems which use 3DES cryptos extensively and we are 
> attempting to re-write some parts of it in Go recently.
> As an initial experiment, we found that the system overall is about 2x~3x 
> slower than the original C version.
> Although the culprit can not be completely singled out yet, the Go pprof 
> tool has shown that about half of the execution time is spent on the DES 
> operation (and the feistel function, specifically).
>
> My question therefore are:
>
> 1. Is the algorithm adopted by crypto/des the most performant one among 
> known DES algorithms? I am really not an expert in the area and have no 
> idea whether there are certain 'advanced' algorithms that could make the C 
> version more efficient. 
>
> 2. If the algorithm used by crypto/des is already optimal, could it be 
> possible due to the quality of the generated code? (FWIW, the systems run 
> on 133MHZ ARMv6 (arm1136 chips))
>
> I have tried with the Go tip (with ARM SSA enabled), which shows an 
> impressive improvement (11mins -> 7mins overall processing time).
> Unfortunately, it's still not enough for replacing an existing system with 
> 2x better performance.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to