ocramz / sparse-linear-algebra

Numerical computation in native Haskell
GNU General Public License v3.0
88 stars 10 forks source link

Improve matrix creation performance #69

Open GregorySchwartz opened 5 years ago

GregorySchwartz commented 5 years ago

When inputting a very large matrix into my program, the majority of the time spent is reading (attoparsec from matrix-market-attoparsec) and matrix creation (the IntM functions). Is there a way to increase performance in both of these libraries? I see that the matrix creation uses lookup for membership existance and then insert, these can be merged into Data.IntMap.Strict.alter, right? I'm sure there are other ways to improve this performance as well...

COST CENTRE          MODULE                           SRC                                                     %time %alloc

insert               Data.Sparse.Internal.IntM        src/Data/Sparse/Internal/IntM.hs:31:1-46                 24.1   46.8
>>=.\.succ'          Data.Attoparsec.Internal.Types   Data/Attoparsec/Internal/Types.hs:146:13-76              13.1    1.9
>>=.\                Data.Attoparsec.Internal.Types   Data/Attoparsec/Internal/Types.hs:(146,9)-(147,44)       11.2    6.5
lookup               Data.Sparse.Internal.IntM        src/Data/Sparse/Internal/IntM.hs:37:1-35                  6.0    0.9
GregorySchwartz commented 5 years ago

Also, not necessarily just for matrix creation, but in general performance I've been having some good identifications of stack usage with this process: http://neilmitchell.blogspot.com/2015/09/detecting-space-leaks.html