diff --git a/src/compiler/GF/Compile/GrammarToLPGF.hs b/src/compiler/GF/Compile/GrammarToLPGF.hs index a00a75eec..7b98f32e5 100644 --- a/src/compiler/GF/Compile/GrammarToLPGF.hs +++ b/src/compiler/GF/Compile/GrammarToLPGF.hs @@ -131,12 +131,13 @@ mkConcrete debug (C.Abstract _ _ _ funs) (C.Concrete modId absModId flags params where val2lin :: C.LinValue -> CodeGen (L.LinFun, Maybe C.LinType) val2lin lv@(C.TableValue _ _) = do + -- val2lin lv@(C.ParamConstant _) = do m <- CMS.get case Map.lookup lv m of Just r -> return r Nothing -> do r <- val2lin' lv - CMS.put (Map.insert lv r m) + CMS.modify (Map.insert lv r) return r val2lin lv = val2lin' lv diff --git a/testsuite/lpgf/README.md b/testsuite/lpgf/README.md index b2738d51f..8a8300c2a 100644 --- a/testsuite/lpgf/README.md +++ b/testsuite/lpgf/README.md @@ -196,6 +196,15 @@ Max memory: 2.25 GB | PhrasebookFin | 135268 | 333 | 0.2% | | PhrasebookFre | 337102 | 76 | 0.02% | +_modify instead of insert_ + +| Concr | Total | Misses | Perc | +|:--------------|-------:|-------:|------:| +| PhrasebookEng | 3211 | 70 | 2% | +| PhrasebookSwe | 7526 | 61 | 1% | +| PhrasebookFin | 135268 | 302 | 0.2% | +| PhrasebookFre | 337102 | 72 | 0.02% | + **Tables** | Concr | Total | Misses | Perc | @@ -205,9 +214,18 @@ Max memory: 2.25 GB | PhrasebookFin | 36875 | 21730 | 59% | | PhrasebookFre | 41397 | 32967 | 80% | +_modify instead of insert_ + +| Concr | Total | Misses | Perc | +|:--------------|------:|-------:|-----:| +| PhrasebookEng | 2415 | 1646 | 68% | +| PhrasebookSwe | 3228 | 2188 | 68% | +| PhrasebookFin | 8793 | 4556 | 52% | +| PhrasebookFre | 12490 | 5793 | 46% | + Conclusions: - map itself requires more memory than acual compilation -- lookup is also as also as actual compilation +- lookup is also as slow as actual compilation Tried HashMap (deriving Hashable for LinValue), no inprovement. Using show on LinValue for keys is incredibly slow.