go-interpreter / proposal

Go-interpreter Project Design Documents
57 stars 0 forks source link

a chez backend proof of concept #5

Closed glycerine closed 6 years ago

glycerine commented 6 years ago

I did a little proof of concept here

https://github.com/go-interpreter/chezgo

It embeds a chez based REPL within Go.

No benchmarks yet, but will do some when I get a moment.

glycerine commented 6 years ago

Initial simple float64 matrix multiply benchmark shows that Chez scheme is about 5x - 8x slower than Go. Go should not be gloating, of course. Go is about 50x slower than Julia for this task, but both Go and Chez are using a suboptimal data structures (slice of slice/vector of vector).

Nonetheless, this is revealing. I think 5-8x slow down could be okay for interactive work. But the bigger thing I learned is that Go has ruined me for other languages, LOL. Its very hard to enjoy trying to force my coding into the anti-imperitive straight jacket that scheme wants to impose. It's just way more fun to write Go.

Lastly, almost in passing, but perhaps this deserves more attention: it might be fruitful to explore Julia more. 400x compared to Chez could make a big, big difference.

sbinet commented 6 years ago

Go is about 50x slower than Julia for this task, but both Go and Chez are using a suboptimal data structures (slice of slice/vector of vector).

I'd be interested to see what the Go code looks like :) (and then the equivalent Gonum-based code)

glycerine commented 6 years ago

Hi Sebastien, the Go code for (unoptimized) matrix multiplication is checked in here:

https://github.com/go-interpreter/chezgo/blob/master/cmd/matmul/matmul.go

https://github.com/go-interpreter/chezgo/blob/master/gonum.go

I did this exercise many years ago and concluded that the highly tuned BLAS libraries like OpenBLAS, GotoBLAS, etc are quite difficult to beat, not in the least because (even before you get to sizes where Volker Strassen's matrix multiplication technique helps) they will multi-thread under the covers unbeknownst to the user; so generally I don't think its a fair comparison to the single threaded vector of vectors in Chez scheme. But the gonum and matmul.go above should both be single threaded. The gonum I'm guessing is using a single vector so it should be more cache friendly.

glycerine commented 6 years ago

After further evaluation, I decided to go with luajit as the initial backend for gi (the renamed gofront). So closing this.