Goのつづき

結論から言うと、ローカルオブジェクトに対するアドレス参照があると、そのオブジェクトをヒープに確保するように動作が変わります。

プログラミング言語Goで謎だった部分

ということで、ループ内でスタック上に確保してるつもりだったRay、Isect、Vecを外に出した。

$ time ./8.out
./8.out  0.14s user 0.01s system 0% cpu 16.340 total

だいたい倍速に。エスケープ解析ください。
でもまだ-O0でコンパイルしたC版の3〜4倍、-O3の7倍か。

The Go project was conceived to make it easier to write the kind of servers and other software Google uses internally, but the implementation isn't quite mature enough yet for large-scale production use.

http://golang.org/doc/go_faq.html

とのことなので、C/C++Perl/Rubyの置き換えっていうよりJava/C#あたりの立ち位置なのかな。