[Cerowrt-devel] fun with go

Dave Taht dave.taht at gmail.com
Wed Dec 7 17:01:09 EST 2016


I needed a break...

I took some time out to try an optimize a critical section in esr's
new loccount tool, which is written in go. From the profile, it
appeared that character at a time I/O was woefully inefficient, and
that replacing it all with mmap would speed things up by at least
2-4x.

Analyzing the linux kernel currently take 24 seconds with loccount,
about 90 sec with sloccount, so we already won big.

But: I couldn't figure out how to make mmap work right in go for this
application, so I rewrote the core routines in C... to get the runtime
in my test code to - wait for it - .668 seconds on my dual core SSD
equipped box. I really wasn't expecting a 30x speedup! And I'm thus
tempted to either rewrite the whole thing in C, or try to figure out
what makes go so slow. Or both.

My (very incomplete) C version is here: https://github.com/dtaht/nloc

And the loccount for go code is here:

https://gitlab.com/esr/loccount

Virtual beer to anyone that can speedup loccount.go by any amount. And
explain why!

-- 
Dave Täht
Let's go make home routers and wifi faster! With better software!
http://blog.cerowrt.org


More information about the Cerowrt-devel mailing list