I wasn't surprised by that until It show that cpu was spending more than half of it on handleReuse.
As it turns out reuseCheckShape(retVal, expectedShape) and more specifically BorrowInts can be very expensive.
It bugged me because I assumed that passing UseUnsafe should prevent the shape checking if I know what I'm passing in WithReuse.
After I made theses changes my program ran twice as fast.
Coverage increased (+0.2%) to 72.127% when pulling e52677802b07a7018c95a16c767cc31e30c99e84 on khezen:master into d5ff158e8ba02c3e4ad3de4932959c4be1bfce94 on gorgonia:master.
Hi fellows,
First of all thanks for the great packages.
I've been using your package to build some MLP models. I was profiling cpu usage with pprof and I shown that most of cpu time was spent on
I wasn't surprised by that until It show that cpu was spending more than half of it on
handleReuse
. As it turns outreuseCheckShape(retVal, expectedShape)
and more specificallyBorrowInts
can be very expensive. It bugged me because I assumed that passingUseUnsafe
should prevent the shape checking if I know what I'm passing inWithReuse
.After I made theses changes my program ran twice as fast.