テキストファイルを処理してMap
(数百万の要素を含む)を構築するHaskellプログラムがあります。全体で 2 ~ 3 分実行できます。-H オプションと -A オプションを微調整すると、実行時間に大きな違いが生じることがわかりました。
RTS のこの機能に関するドキュメントがありますが、GC 理論のアルゴリズムと用語を知らないので、私には読みにくいです。Haskell/GHC に固有の、より技術的な説明を探しています。これらのオプションに適切な値を選択することについての参照はありますか?
編集:それがコードです。指定された単語のリストに対してトライを構築します。
buildTrie :: [B.ByteString] -> MyDFA
buildTrie l = fst3 $ foldl' step (emptyDFA, B.empty, 1) $ sort $ map B.reverse l where
step :: (MyDFA , B.ByteString, Int) -> B.ByteString -> (MyDFA , B.ByteString, Int)
step (dfa, lastWord, newIndex) newWord = (insertNewStates, newWord, newIndex + B.length newSuffix) where
(pref, lastSuffix, newSuffix) = splitPrefix lastWord newWord
branchPoint = transStar dfa pref
--new state labels for the newSuffix path
newStates = [newIndex .. newIndex + B.length newSuffix - 1]
--insert newStates
insertNewStates = (foldl' (flip insertTransition) dfa $ zip3 (branchPoint:init newStates) (B.unpack newSuffix) newStates)