Interesting. Thanks for sharing. I used to confront with a similar scenario in the C world, where we had to use *sched_setscheduler(2) *to prevent the OS scheduler from interfering with our application, which requires a below ~50ms variation IIRC. Yeah, it happened even though the application was written in an unmanaged and non-GC language.
On Sunday, August 28, 2016 at 12:07:39 PM UTC+8, Sam Whited wrote: > > On Sat, Aug 27, 2016 at 11:43 AM, mura <aruma...@gmail.com <javascript:>> > 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.