Hacker News new | ask | show | jobs
by lossolo 2618 days ago
Probably because Go version is different, compare C vector operations with Go vector operations. C version is operating on pointer without allocating new vector, Go version is allocation new vector on every op.

EDIT: Look at C code assembly, it's generating mostly SIMD instructions and using xmm registers. That's why it's faster. Golang compiler still do not have autovectorization implemented that's why it's so much slower in this case.

EDIT2: It seems Go version also uses SSE here, which is nice. So probably unnecessary allocation from my original post was the reason.

1 comments

I modified the Go version to pass references (see my second edit) and that made up the difference (or I mistranslated).
Ah, you replied to my comment before the edit, about unnecessary allocation in Go vec handling.
I'm 99% sure the Go version doesn't allocate any vectors; afaict, it's passing everything on the stack.