1 Commits

Author SHA1 Message Date
John J. Camilleri
3e2673de3b Use modify instead of insert: results mildly better but not significantly 2021-03-16 16:45:57 +01:00
2 changed files with 21 additions and 2 deletions

View File

@@ -131,12 +131,13 @@ mkConcrete debug (C.Abstract _ _ _ funs) (C.Concrete modId absModId flags params
where where
val2lin :: C.LinValue -> CodeGen (L.LinFun, Maybe C.LinType) val2lin :: C.LinValue -> CodeGen (L.LinFun, Maybe C.LinType)
val2lin lv@(C.TableValue _ _) = do val2lin lv@(C.TableValue _ _) = do
-- val2lin lv@(C.ParamConstant _) = do
m <- CMS.get m <- CMS.get
case Map.lookup lv m of case Map.lookup lv m of
Just r -> return r Just r -> return r
Nothing -> do Nothing -> do
r <- val2lin' lv r <- val2lin' lv
CMS.put (Map.insert lv r m) CMS.modify (Map.insert lv r)
return r return r
val2lin lv = val2lin' lv val2lin lv = val2lin' lv

View File

@@ -196,6 +196,15 @@ Max memory: 2.25 GB
| PhrasebookFin | 135268 | 333 | 0.2% | | PhrasebookFin | 135268 | 333 | 0.2% |
| PhrasebookFre | 337102 | 76 | 0.02% | | 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** **Tables**
| Concr | Total | Misses | Perc | | Concr | Total | Misses | Perc |
@@ -205,9 +214,18 @@ Max memory: 2.25 GB
| PhrasebookFin | 36875 | 21730 | 59% | | PhrasebookFin | 36875 | 21730 | 59% |
| PhrasebookFre | 41397 | 32967 | 80% | | 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: Conclusions:
- map itself requires more memory than acual compilation - 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. Tried HashMap (deriving Hashable for LinValue), no inprovement.
Using show on LinValue for keys is incredibly slow. Using show on LinValue for keys is incredibly slow.