gonum / matrix

Matrix packages for the Go language [DEPRECATED]
446 stars 51 forks source link

mat64: improve i/o performances #346

Closed sbinet closed 8 years ago

sbinet commented 8 years ago

calling binary.Write(w, binary.LittleEndian, v) in a tight-ish loop, especially when v=int64|float64, is less than optimized.

fix it.

sbinet commented 8 years ago

see https://github.com/sbinet/npyio/commit/dca281fae51d31857da5490c10bca634b16132b6 for the kind of performances one can recoup

kortschak commented 8 years ago

How does that compare with the user providing a bufio.Buffer as the target io.Writer?

sbinet commented 8 years ago

dunno. the benchmark numbers were crafted with a ioutil.Discard. I doubt it would make a difference (most likely the price is, as I said, coming from the reflection happening inside binary.Write. price we pay for each element of the slice.)

sbinet commented 8 years ago

as part of a PR fixing this issue, I'll create also a few r/w benchmarks for Dense and Vector. this should also be interesting to make sure #344 does not introduce any performance regression.

kortschak commented 8 years ago

Yeah, I think you are right. I think your approach is the correct one.

sbinet commented 8 years ago

354 adds basic r/w benchmarks so we have a baseline to compare against before doing any optimization.

sbinet commented 8 years ago

and, as can be seen above, I have a CL (not yet a PR) leveraging these benchmarks to show some interesting improvements: https://github.com/sbinet/gonum-matrix/commit/73a71bae30ddee85690b1c0c0ec601c85e2abcfa