GopherJS is really cool, i just want to see the real world Go questions asked and answered.
Surprises in GopherJS Performance
21–29 of 29 posts
Re: Surprises in GopherJS Performance
#22Great article on the complexities of investigating performance issues! Another very interesting surprise is when I run this locally on my macbook, clang is much faster mac >> go run main.go approximating pi with 1000000000 iterations. 3.1415926545880506 total time taken is: 9.706911232s mac >> clang++ -O3 -ffast-math -march=native main.cpp mac >> ./a.out 3.1415926545864963 total time taken is: 2.14196s
Re: Surprises in GopherJS Performance
#23Great article on the complexities of investigating performance issues! Another very interesting surprise is when I run this locally on my macbook, clang is much faster mac >> go run main.go approximating pi with 1000000000 iterations. 3.1415926545880506 total time taken is: 9.706911232s mac >> clang++ -O3 -ffast-math -march=native main.cpp mac >> ./a.out 3.1415926545864963 total time taken is: 2.14196s
The speed of the answer doesn't matter so much when the answer is wrong. And (after checking Google) BOTH of those are wrong. :/
mac >> clang++ -O3 -march=native main.cpp
mac >> ./a.out
3.1415926545880506
total time taken is: 4.3861569999999999s
Twice as slow as the fastmath version but still faster than the go version.Re: Surprises in GopherJS Performance
#24I always expect these stories to be about a JS client for Gopher... and I guess I'm always a bit disappointed.
Re: Surprises in GopherJS Performance
#25Great article on the complexities of investigating performance issues! Another very interesting surprise is when I run this locally on my macbook, clang is much faster mac >> go run main.go approximating pi with 1000000000 iterations. 3.1415926545880506 total time taken is: 9.706911232s mac >> clang++ -O3 -ffast-math -march=native main.cpp mac >> ./a.out 3.1415926545864963 total time taken is: 2.14196s
The speed of the answer doesn't matter so much when the answer is wrong. And (after checking Google) BOTH of those are wrong. :/
100,50,25,12,4,2,3,3.5
> 3.5
Or even: 100,90,80,70,60,50,40
> 40
I'm assuming you mean wrong as in the algorithm implemented with arbitrary precision would en up with a different set of digits for the number of iterations given? Or something along those lines?Re: Surprises in GopherJS Performance
#26Earlier quoted context omitted.
The speed of the answer doesn't matter so much when the answer is wrong. And (after checking Google) BOTH of those are wrong. :/
Clearly the two results are different, so something strange is going on. But you need to define wrong, consider incrementally approximating pi in 7 steps: 100,50,25,12,4,2,3,3.5 > 3.5 Or even: 100,90,80,70,60,50,40 > 40 I'm assuming you mean wrong as in the algorithm implemented with arbitrary precision would en up with a different set of digits for the number of iterations given? Or something along those lines?
It's probably more a problem of the algorithm not calculating significant figures and truncating the answer.
Re: Surprises in GopherJS Performance
#27Earlier quoted context omitted.
Clearly the two results are different, so something strange is going on. But you need to define wrong, consider incrementally approximating pi in 7 steps: 100,50,25,12,4,2,3,3.5 > 3.5 Or even: 100,90,80,70,60,50,40 > 40 I'm assuming you mean wrong as in the algorithm implemented with arbitrary precision would en up with a different set of digits for the number of iterations given? Or something along those lines?
Oh, I mean they're both wrong in the 10th position even though they agree. But it is curious that they diverge after that. It's probably more a problem of the algorithm not calculating significant figures and truncating the answer.
So is it possible that the algorithm doesn't converge to correct digits for so "few" iterations?
Re: Surprises in GopherJS Performance
#28Earlier quoted context omitted.
Clearly the two results are different, so something strange is going on. But you need to define wrong, consider incrementally approximating pi in 7 steps: 100,50,25,12,4,2,3,3.5 > 3.5 Or even: 100,90,80,70,60,50,40 > 40 I'm assuming you mean wrong as in the algorithm implemented with arbitrary precision would en up with a different set of digits for the number of iterations given? Or something along those lines?
Oh, I mean they're both wrong in the 10th position even though they agree. But it is curious that they diverge after that. It's probably more a problem of the algorithm not calculating significant figures and truncating the answer.
This particular series, which comes from a series for the arctan of 1, has very slow convergence. An easily better one is Machin's formula, which converges faster than a geometric series (that is, the number of terms needed is at most linear in the number of wanted digits).
Re: Surprises in GopherJS Performance
#29>> low-level C implementation compiled with -O3, the max optimization setting. IME, -O2 always comes out faster than -O3. In this case, though, the difference is fairly insignificant.