Hi!
I have a small performance challenge for the go nuts out there!
Goal: store in memory (e.g. slice) all regular files from a folder recursively,
do not follow symlinks. Printing the result should output something similar to
`find $1 -type f`. Storage and output need not be sorted. Bonus if
non-concurrent.
I noticed a significant (approx. 2x) performance difference on Linux amd64
between my quick-and-dirty C implementation:
https://gist.github.com/Ambrevar/8a9f3cb2a22c2b67b86b
and my (naive?) Go implementation:
http://play.golang.org/p/TPrXUXBMYs
Benchmarks are done on hot cache and sane hardware (SSD).
I tried a few different approaches:
* Unwrapping the abstraction by using mostly syscalls did help a
little (~10-20% better), but still far from optimal. Besides, I lose
portability. (Well, the C version is not the most portable either.)
*
github.com/kr/fs: nice, but still too slow.
*
github.com/mirtchovski/walk: not much faster.
*
github.com/MichaelTJones/walk is reaching C performance when GOMAXPROCS >= 2, but still twice as slow when GOMAXPROCS==1.
* I did not spot any obvious bottleneck from profiling.
Any clue how to make this faster?
Cheers!
--
Pierre Neidhardt
Vitamin C deficiency is apauling.