Hi! I'm the author. I do have an ivory tower compsci degree. I'm poking fun at myself as much as anyone else.
> There are some good bits of advice in the article, too, though.
Thanks! "Everything Sysadmin" is my 3x/yearly column in ACM Queue. My goal is to bring a bit of operational reality to an organization with a reputation for being ivory tower. Click on the phrase "everything sysadmin" to see the other columns I've written.
> So, when you are using C/C++, "small" for this problem is a billion elements.
I know, right? "Small" has gotten so big that we have to re-think our gut reactions and recalibrate our back-of-the-envelope estimations. Just imagine how big small will be for the next generation of developers?
about the same, since moores law is dead for cpus, and ram doesnt seem to be getting much faster either
Are you saying you need 50 clock cycles to compare two integers?
func BenchmarkFindMax(b *testing.B) {
ints := make([]int32, 13*1000*100)
for i := 0; i < len(ints); i++ {
ints[i] = rand.Int31()
}
for i := 0; i < b.N; i++ {
max := int32(math.MinInt32)
for _, x := range ints {
if x > max {
max = x
}
}
dontOptimize = max
}
b.ReportMetric(float64(b.N*len(ints)*4/1000/1000/1000),
"GiB/s")
}
goos: darwin
goarch: amd64
BenchmarkFindMax-8 1530 678975 ns/op 7.00 GiB/s
EDIT: Actually my original code was reporting the metric wrong, it should have been:b.ReportMetric(float64(b.N)float64(len(ints))4/1000/1000/1000, "GiB/s")
which leads to 9-10GiB/s on my laptop
Benchmark comparisons are useless without running on equivalent hardware.
The point of my benchmark was that C is nowhere near 50-100x faster than Go and that the user I'm replying to shouldn't make unsubstantiated claims like that.
It's rather obvious I compared against the quoted figure.
In a language with lazy stream abstraction, the max() function can be pretty efficient.
There are some good bits of advice in the article, too, though.
> I conducted some simple benchmarks in Go to find how much data can be processed in 200 ms. A linear search can scan 13 million elements in less than 200 ms on a three-year-old MacBook laptop, and 13 million is no small feat.
It's funny how slow languages have shifted perceptions. Scanning 13 million elements to find the biggest element among 32 bit ints in 200 ms is slow. That's 250 MB/s, or about 50 clock cycles per element. Even the most naive and portable C three-liner is almost 100x faster (there is a difference in single-threaded performance, if you assume a very generous 50 % difference, it'd still be 50x faster).
So, when you are using C/C++, "small" for this problem is a billion elements.Computers are super-fast. Next time you wait two seconds for some application to compute something, ask yourself: is this problem really eight-billion clock cycles hard?