| 1 |
Currently (2020-10-14), 4.5 GiB are taken up by parsing the Ding source |
| 2 |
(which is 20 MiB in size). |
| 3 |
|
| 4 |
The main issue is that the program cannot start writing to disk before |
| 5 |
essentially the whole dictionary is processed, because the (prefixing) TEI |
| 6 |
header wants to know the number of TEI entries. |
| 7 |
|
| 8 |
|
| 9 |
-- Obsolete: |
| 10 |
|
| 11 |
This huge memory usage probably is due to something in the Happy-generated |
| 12 |
code. |
| 13 |
|
| 14 |
The usage can likely be drastically be reduced by having Happy only parse |
| 15 |
single lines. |
| 16 |
|
| 17 |
This requires parsing the header separately, though (which should not be |
| 18 |
difficult). |
| 19 |
|
| 20 |
Testing with restricted memory: |
| 21 |
$ ulimit -S -d #N_KB |
| 22 |
* result: restricting to below 2.6 GiB crashes the program. |
| 23 |
|
| 24 |
|
| 25 |
Testing repeated inspection: |
| 26 |
|
| 27 |
> putStrLn $ show $ length ls |
| 28 |
> threadDelay $ 20 * 1000 * 1000 |
| 29 |
> putStrLn $ show $ length $ show ls |
| 30 |
|
| 31 |
* second counting finishes fast |
| 32 |
* no memory reduction after first counting done noticeable. |
| 33 |
|
| 34 |
|
| 35 |
Results of improvement (scan & parse by line) |
| 36 |
* scan&parse time: 20s -> 13s |
| 37 |
* scan time: 4s -> 10s (likely I did something wrong in measuring) |
| 38 |
* memory usage: 2.6 GiB -> 2.7 MiB |
| 39 |
* Note: lazyness and garbage collection have a huge impact here |