<div dir="ltr"><div>Hi,</div><div><br></div><div>I've encountered an enormous memory usage (and long run times) of mpost when running in the decimal/binary mode and processing a lot of stored paths.</div><div><br></div><div>It can be demonstrated on the following cycle (the exact path definition doesn't matter but should be long enough to make the issue obvious):</div><div><br></div><div>path p;<br>for i:= 0 upto 4000:<br>    p:=(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..<br>       (0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40)..(0,0)..(10,10)..(2,8)..(5,40);<br>endfor;<br>end.<br></div><div><br></div>It uses gigabytes of memory in the decimal mode (and somewhat less in binary), so something is probably going wrong:<br><div><br></div><div>        Command being timed: "mpost --numbersystem=scaled <a href="http://test.mp">test.mp</a>"<br>        User time (seconds): 1.42<br>        Maximum resident set size (kbytes): 40768<br><br>        Command being timed: "mpost --numbersystem=double <a href="http://test.mp">test.mp</a>"<br>        User time (seconds): 0.61<br>        Maximum resident set size (kbytes): 41728<br>        <br>        Command being timed: "mpost --numbersystem=decimal <a href="http://test.mp">test.mp</a>"<br>        User time (seconds): 498.56<br>        Maximum resident set size (kbytes): 37244480<br>        <br>        Command being timed: "mpost --numbersystem=binary <a href="http://test.mp">test.mp</a>"<br>        User time (seconds): 187.32<br>        Maximum resident set size (kbytes): 10906672<br><br></div><div>After some experiments with the number of loop repetitions it seems that the memory usage (and the run time) increases linearly with the number of iterations.</div><div><br></div><div>MP version: This is MetaPost, version 2.02 (TeX Live 2022/Debian) (kpathsea version 6.3.4)</div><div><br></div><div>Best wishes</div><div>Martin</div></div>