Use unboxed array for the main matrix
huffyhenry opened this issue · 5 comments
huffyhenry commented
Use unboxed array for the main matrix
huffyhenry commented
See https://stackoverflow.com/questions/32123475/profiling-builds-with-stack for instructions how to profile with stack and https://making.pusher.com/memory-profiling-in-haskell/ for an example.
huffyhenry commented
Asked a question on SO https://stackoverflow.com/questions/53692617/memory-usage-of-a-recursive-array-in-haskell
huffyhenry commented
huffyhenry commented
The cause of the high memory footprint is "boxing": as I understand it, Haskell keeps the full computation of the array entries instead of the final value. Use unboxed arrays instead. Things to keep in mind:
- Only simple types can be held in unboxed arrays, how do we keep an
Entry
? Do we need two arrays here? - We need to define the entries in the correct order - not hard, since N-W arrays can be filled row by row.
huffyhenry commented
Example use of the key STUArray
type: https://stackoverflow.com/questions/8197032/starray-documentation-for-newbies-and-state-st-related-questions