get for UArray blows the heap for large arrays
- 主要言語
- Haskell
- スター
- 120
- フォーク
- 70
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
``` haskell
instance (Binary i, Ix i, Binary e, IArray UArray e) => Binary (UArray i e) where
get = do
bs <- get
n <- get
xs <- getMany n
return (listArray bs xs)
```
getMany is fully strict in the list, since it uses an accumulator and reverses it at the end. The intermediate xs list can be huge in cases where the eventual UArray is much more manageable (eg 28M Booleans).
Two questions:
1) Is there a known alternative for (un)serializing UArrays to(from) disk? Such an alternative would make this Issue far less important.
2) Have you considered a version that serializes the bytes directly? I drafted one up; it's tremendously more efficient, though I'm concerned about robustness wrt endianness etc. Furthermore, it requires a base monad that can mutate arrays, which requires an "unsafe" invocation. And lastly it's not portable, using ghc-prim.
HTH. Thanks.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Binary (UArray i e) の get インスタンスとその getMany パスから始め、大きな Boolean UArray のデコードを再現して、中間リストのメモリ使用量を測定します。提案されている direct-byte アプローチを、エンディアン、可変性、ghc-prim の移植性、ディスクシリアライズの代替案の観点から検討します。完了の条件は、合意されたスコープと、ヒープの急激な膨張を回避するテスト済みの UArray シリアライズパスです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- haskell
- 領域
- data
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100