[plt-scheme] Why is my program slowing down?
Hello
I have a program I've written with DrScheme, quite an elaborate one that
has a lot of data - it's for icfp (for fun, of course).
It's supposed to eventually handle 10,000 cells and 182 ants, and
thousands of commands for them, but I'm running it on tiny.world and
sample.ant which means 100 cells, 32 ants and only about 400 commands.
It is already running too slow, taking 219 ms for the first 10 rounds,
and for rounds 1240-1250 it takes 2125 ms.
At this rate, at round 12500 it will take about 20 seconds per 10
rounds, and at the final rounds 99990 - 100000, it will take about 160
per ten rounds.
I've been wondering why my program slows down like that?
It has quite a constant amount of memory use, but (current-memory-use)
is also going up; a log follows.
As you can see, memory use goes up quite fast and I have no idea why; my
program is tail recursive, and each step uses set! on the world and ants
and removes old data; what could cause that memory increase and
slowdown?
I have disable debugging before creating the executable.
ifconfig.
0. Current-process-milliseconds: 437. [since last: 437]
current-memory-use: 2150400.
10. Current-process-milliseconds: 656. [since last: 219]
current-memory-use: 2260992.
20. Current-process-milliseconds: 953. [since last: 297]
current-memory-use: 2134016.
30. Current-process-milliseconds: 1203. [since last: 250]
current-memory-use: 2539520.
40. Current-process-milliseconds: 1406. [since last: 203]
current-memory-use: 2494464.
50. Current-process-milliseconds: 1671. [since last: 265]
current-memory-use: 2338816.
60. Current-process-milliseconds: 1937. [since last: 266]
current-memory-use: 2310144.
70. Current-process-milliseconds: 2234. [since last: 297]
current-memory-use: 2408448.
80. Current-process-milliseconds: 2515. [since last: 281]
current-memory-use: 2449408.
90. Current-process-milliseconds: 2859. [since last: 344]
current-memory-use: 3055616.
100. Current-process-milliseconds: 3203. [since last: 344]
current-memory-use: 2842624.
110. Current-process-milliseconds: 3531. [since last: 328]
current-memory-use: 2662400.
120. Current-process-milliseconds: 3875. [since last: 344]
current-memory-use: 2723840.
130. Current-process-milliseconds: 4218. [since last: 343]
current-memory-use: 2220032.
140. Current-process-milliseconds: 4593. [since last: 375]
current-memory-use: 2859008.
150. Current-process-milliseconds: 4906. [since last: 313]
current-memory-use: 2723840.
160. Current-process-milliseconds: 5296. [since last: 390]
current-memory-use: 2244608.
170. Current-process-milliseconds: 5734. [since last: 438]
current-memory-use: 2736128.
180. Current-process-milliseconds: 6093. [since last: 359]
current-memory-use: 2949120.
190. Current-process-milliseconds: 6546. [since last: 453]
current-memory-use: 2654208.
200. Current-process-milliseconds: 7031. [since last: 485]
current-memory-use: 2473984.
210. Current-process-milliseconds: 7484. [since last: 453]
current-memory-use: 2457600.
220. Current-process-milliseconds: 8062. [since last: 578]
current-memory-use: 2473984.
230. Current-process-milliseconds: 8562. [since last: 500]
current-memory-use: 2248704.
240. Current-process-milliseconds: 9093. [since last: 531]
current-memory-use: 2555904.
250. Current-process-milliseconds: 9671. [since last: 578]
current-memory-use: 2310144.
260. Current-process-milliseconds: 10203. [since last: 532]
current-memory-use: 2535424.
270. Current-process-milliseconds: 10750. [since last: 547]
current-memory-use: 2351104.
280. Current-process-milliseconds: 11218. [since last: 468]
current-memory-use: 2269184.
290. Current-process-milliseconds: 11656. [since last: 438]
current-memory-use: 2883584.
300. Current-process-milliseconds: 12234. [since last: 578]
current-memory-use: 2686976.
310. Current-process-milliseconds: 12796. [since last: 562]
current-memory-use: 3571712.
320. Current-process-milliseconds: 13531. [since last: 735]
current-memory-use: 2908160.
330. Current-process-milliseconds: 14203. [since last: 672]
current-memory-use: 2777088.
340. Current-process-milliseconds: 14828. [since last: 625]
current-memory-use: 2605056.
350. Current-process-milliseconds: 15453. [since last: 625]
current-memory-use: 3035136.
360. Current-process-milliseconds: 16171. [since last: 718]
current-memory-use: 2863104.
370. Current-process-milliseconds: 16828. [since last: 657]
current-memory-use: 3006464.
380. Current-process-milliseconds: 17531. [since last: 703]
current-memory-use: 2777088.
390. Current-process-milliseconds: 18234. [since last: 703]
current-memory-use: 2473984.
400. Current-process-milliseconds: 19062. [since last: 828]
current-memory-use: 2801664.
410. Current-process-milliseconds: 19765. [since last: 703]
current-memory-use: 2867200.
420. Current-process-milliseconds: 20453. [since last: 688]
current-memory-use: 2441216.
430. Current-process-milliseconds: 21203. [since last: 750]
current-memory-use: 2310144.
440. Current-process-milliseconds: 22078. [since last: 875]
current-memory-use: 2957312.
450. Current-process-milliseconds: 22906. [since last: 828]
current-memory-use: 2441216.
460. Current-process-milliseconds: 23734. [since last: 828]
current-memory-use: 2256896.
470. Current-process-milliseconds: 24546. [since last: 812]
current-memory-use: 2662400.
480. Current-process-milliseconds: 25500. [since last: 954]
current-memory-use: 2551808.
490. Current-process-milliseconds: 26265. [since last: 765]
current-memory-use: 2662400.
500. Current-process-milliseconds: 27187. [since last: 922]
current-memory-use: 3006464.
510. Current-process-milliseconds: 28203. [since last: 1016]
current-memory-use: 3170304.
520. Current-process-milliseconds: 29125. [since last: 922]
current-memory-use: 2719744.
530. Current-process-milliseconds: 30234. [since last: 1109]
current-memory-use: 3047424.
540. Current-process-milliseconds: 31156. [since last: 922]
current-memory-use: 2842624.
550. Current-process-milliseconds: 32203. [since last: 1047]
current-memory-use: 3002368.
560. Current-process-milliseconds: 33234. [since last: 1031]
current-memory-use: 2281472.
570. Current-process-milliseconds: 34265. [since last: 1031]
current-memory-use: 3137536.
580. Current-process-milliseconds: 35296. [since last: 1031]
current-memory-use: 2371584.
590. Current-process-milliseconds: 36203. [since last: 907]
current-memory-use: 2371584.
600. Current-process-milliseconds: 37203. [since last: 1000]
current-memory-use: 2281472.
610. Current-process-milliseconds: 38265. [since last: 1062]
current-memory-use: 3080192.
620. Current-process-milliseconds: 39296. [since last: 1031]
current-memory-use: 2637824.
630. Current-process-milliseconds: 40328. [since last: 1032]
current-memory-use: 2392064.
640. Current-process-milliseconds: 41562. [since last: 1234]
current-memory-use: 2392064.
650. Current-process-milliseconds: 42734. [since last: 1172]
current-memory-use: 2293760.
660. Current-process-milliseconds: 43906. [since last: 1172]
current-memory-use: 2945024.
670. Current-process-milliseconds: 45078. [since last: 1172]
current-memory-use: 2359296.
680. Current-process-milliseconds: 46296. [since last: 1218]
current-memory-use: 2891776.
690. Current-process-milliseconds: 47484. [since last: 1188]
current-memory-use: 2306048.
700. Current-process-milliseconds: 48734. [since last: 1250]
current-memory-use: 3211264.
710. Current-process-milliseconds: 50046. [since last: 1312]
current-memory-use: 2678784.
720. Current-process-milliseconds: 51343. [since last: 1297]
current-memory-use: 2433024.
730. Current-process-milliseconds: 52796. [since last: 1453]
current-memory-use: 2375680.
740. Current-process-milliseconds: 54390. [since last: 1594]
current-memory-use: 2719744.
750. Current-process-milliseconds: 56000. [since last: 1610]
current-memory-use: 3063808.
760. Current-process-milliseconds: 57531. [since last: 1531]
current-memory-use: 3063808.
770. Current-process-milliseconds: 59109. [since last: 1578]
current-memory-use: 3067904.
780. Current-process-milliseconds: 60718. [since last: 1609]
current-memory-use: 3129344.
790. Current-process-milliseconds: 62468. [since last: 1750]
current-memory-use: 2453504.
800. Current-process-milliseconds: 64312. [since last: 1844]
current-memory-use: 2699264.
810. Current-process-milliseconds: 66296. [since last: 1984]
current-memory-use: 2637824.
820. Current-process-milliseconds: 68140. [since last: 1844]
current-memory-use: 3006464.
830. Current-process-milliseconds: 70296. [since last: 2156]
current-memory-use: 2342912.
840. Current-process-milliseconds: 72390. [since last: 2094]
current-memory-use: 2867200.
850. Current-process-milliseconds: 74515. [since last: 2125]
current-memory-use: 2408448.
860. Current-process-milliseconds: 76156. [since last: 1641]
current-memory-use: 3194880.
870. Current-process-milliseconds: 77609. [since last: 1453]
current-memory-use: 3063808.
880. Current-process-milliseconds: 79078. [since last: 1469]
current-memory-use: 3260416.
890. Current-process-milliseconds: 80625. [since last: 1547]
current-memory-use: 2494464.
900. Current-process-milliseconds: 81984. [since last: 1359]
current-memory-use: 3260416.
910. Current-process-milliseconds: 83562. [since last: 1578]
current-memory-use: 2842624.
920. Current-process-milliseconds: 85156. [since last: 1594]
current-memory-use: 2703360.
930. Current-process-milliseconds: 86765. [since last: 1609]
current-memory-use: 2842624.
940. Current-process-milliseconds: 88281. [since last: 1516]
current-memory-use: 2736128.
950. Current-process-milliseconds: 89890. [since last: 1609]
current-memory-use: 2883584.
960. Current-process-milliseconds: 91312. [since last: 1422]
current-memory-use: 2883584.
970. Current-process-milliseconds: 93015. [since last: 1703]
current-memory-use: 3178496.
980. Current-process-milliseconds: 94593. [since last: 1578]
current-memory-use: 3178496.
990. Current-process-milliseconds: 96156. [since last: 1563]
current-memory-use: 2535424.
1000. Current-process-milliseconds: 97781. [since last: 1625]
current-memory-use: 3002368.
1010. Current-process-milliseconds: 99437. [since last: 1656]
current-memory-use: 3002368.
1020. Current-process-milliseconds: 101218. [since last: 1781]
current-memory-use: 3002368.
1030. Current-process-milliseconds: 102843. [since last: 1625]
current-memory-use: 2613248.
1040. Current-process-milliseconds: 104640. [since last: 1797]
current-memory-use: 2924544.
1050. Current-process-milliseconds: 106359. [since last: 1719]
current-memory-use: 2883584.
1060. Current-process-milliseconds: 108281. [since last: 1922]
current-memory-use: 3293184.
1070. Current-process-milliseconds: 110109. [since last: 1828]
current-memory-use: 2883584.
1080. Current-process-milliseconds: 111843. [since last: 1734]
current-memory-use: 2801664.
1090. Current-process-milliseconds: 113500. [since last: 1657]
current-memory-use: 2801664.
1100. Current-process-milliseconds: 115234. [since last: 1734]
current-memory-use: 2662400.
1110. Current-process-milliseconds: 116843. [since last: 1609]
current-memory-use: 3006464.
1120. Current-process-milliseconds: 118296. [since last: 1453]
current-memory-use: 4296704.
1130. Current-process-milliseconds: 119703. [since last: 1407]
current-memory-use: 3608576.
1140. Current-process-milliseconds: 121265. [since last: 1562]
current-memory-use: 3952640.
1150. Current-process-milliseconds: 122781. [since last: 1516]
current-memory-use: 3588096.
1160. Current-process-milliseconds: 124312. [since last: 1531]
current-memory-use: 3678208.
1170. Current-process-milliseconds: 125828. [since last: 1516]
current-memory-use: 2596864.
1180. Current-process-milliseconds: 127468. [since last: 1640]
current-memory-use: 4399104.
1190. Current-process-milliseconds: 129156. [since last: 1688]
current-memory-use: 3137536.
1200. Current-process-milliseconds: 130718. [since last: 1562]
current-memory-use: 3948544.
1210. Current-process-milliseconds: 132437. [since last: 1719]
current-memory-use: 2617344.
1220. Current-process-milliseconds: 133890. [since last: 1453]
current-memory-use: 2617344.
1230. Current-process-milliseconds: 135500. [since last: 1610]
current-memory-use: 2617344.
1240. Current-process-milliseconds: 137625. [since last: 2125]
current-memory-use: 2899968.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20040606/37b71136/attachment.html>