On Sat, Aug 27, 2016 at 11:43 AM, mura <arumaka...@gmail.com> wrote:
> 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).

Warning: mere speculation follows.

With long calculations involving many iterations (such as the
iterations in any block cipher, or, I suspect, the feistel function) I've had
performance issues in the past due to the cost of the scheduler
preempting goroutines. Limiting the number of concurrent workers
running DES calls may be beneficial.

With blowfish I've also had good results turning up the
maximum aggressiveness (specifically by adjusting the "hairiness"
metric) of the inliner; this makes the final binary bigger, but may
also prevent the sheduler from preempting a goroutine performing a DES
operation by inlining the function calls within the iterations. This
may apply to the feistel function as well.

Finally, I haven't tried it, but using runtime.LockOSThread
may have similar results, if my understanding of that function is
correct and it prevents the scheduler from preempting the goroutine
until it completes or the goroutine releases the underlying thread.
Importing the runtime package (to say nothing of building a custom
version of the compiler) should probably be saved as a last resort,
but it may be worth testing to see if it improves your performance at
all.

Chances are, you're better off just using a different implementation
that is optimized for performance.

—Sam


-- 
Sam Whited
pub 4096R/54083AE104EA7AD3

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