Summary: | Repetitive calls to reserveInnerVectors in SparseMatrix::insert | ||
---|---|---|---|
Product: | Eigen | Reporter: | Gael Guennebaud <gael.guennebaud> |
Component: | Sparse | Assignee: | Nobody <eigen.nobody> |
Status: | CONFIRMED --- | ||
Severity: | Performance Problem | CC: | chtz, emanuel.schmid, gael.guennebaud, j.v.dijk |
Priority: | Normal | ||
Version: | 3.4 (development) | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
Gael Guennebaud
2017-06-23 15:40:59 UTC
Indeed, the condition m_data.size() != m_data.allocatedSize() is never satisfied, and reserveInnerVectors is called every time. One solution would be to call m_data.resize(allocatedSize()) after the call to this->reserveInnerVectors(). This is equivalent to putting all the remaining allocated space to the last column. This is not 100% optimal if someone calls reserveInnerVectors by himself, e.g.: SparseMatrix A; // make A huge A.setZero(); A.resize(small,small); A.reserveInnerVectors(....); A.insert(...); In this case reserveInnerVectors will still be called at the first call to insert(), but that should be OK. Is there any plan to implement the change that was suggested by Gael above? I stumbled on this report after finding out (using valgrind) that our simulation code spent 80% of the time in reserveInnerVectors. Our use case seems to be comparable to that of Emanuel. (And also for us triplet-based matrix assembly is not practical.) I think that most users, like me, expect more decent performance than is presently achieved when reserve_nnz is used. At present using Eigen results in 5-10 times worse performance than obtained with other matrix-vector libraries that our code can be configured to use. The one-liner change suggested above makes Eigen shine again. -- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1443. |