From: DAVID G. <dav...@ro...> - 2005-08-19 22:54:48
|
Steve's finding reminded me of a problem I'd had a long time back. The result was hard to explain. It's not necessarily problem, just that the memory usage was a bit unexpected. The interaction with the string memory problem just brought it to light. The same program that pathologically beat up on the string area, also used coexpressions. This caused Icon to report on collections in the static area. I think it might have been Ralph Griswold who clarified that the numbers were a phantom and it really wasn't collecting that region. The problem was caused because I was using coexpressions and a lot of them. (It was pre-unicon and I needed something that maintained a state but there was nothing lighter available). I recall that coexpressions save the entire state of the local procedure which can be quite wasteful. The sample code and results show the effect. The solution was to wrap the cooexpression in a minimal procedure. There followed a discussion with some other folks on the about a lighter weight construct that had been experimented with (or abandoned) earlier. Of course, an object would probably do handily now, but this was Icon. I cobbled together a few lines (below) to see if GC behaves the same way. It appears that it does. I also recall that at some point the regions try and expand, but it looks like I'm nowhere near that point. So if those static region statistics are phantoms, I wonder what they are counting? David # -- The results -- coexp-gc thin 1000 1000 collections : 38 38 0 0 storage: - 0 12 144 regions: - 0 7371325 7371325 coexp-gc fat 1000 1000 collections : 38 38 0 0 storage: - 0 1011 152 regions: - 0 7371325 7371325 coexp-gc fat 10000 10000 collections : 390 384 6 0 storage: - 0 10013 152 regions: - 0 7371325 7371325 coexp-gc fat 20000 20000 collections : 796 769 27 0 storage: - 0 20013 152 regions: - 0 7371325 7371325 coexp-gc fat 20000 100000 collections : 1453 769 684 0 storage: - 0 100014 152 regions: - 0 7371325 7371325 coexp-gc fat 20000 500000 collections : 18850 769 18081 0 storage: - 0 500014 152 regions: - 0 7371325 7371325 coexp-gc fat 10000 20000 collections : 411 384 27 0 storage: - 0 20013 152 regions: - 0 7371325 7371325 coexp-gc fat 50000 20000 collections : 1950 1923 27 0 storage: - 0 20013 152 regions: - 0 7371325 7371325 coexp-gc fat 100000 20000 collections : 3873 3846 27 0 storage: - 0 20014 152 regions: - 0 7371325 7371325 coexp-gc fat 500000 20000 collections : 19257 19230 27 0 storage: - 0 20014 152 regions: - 0 7371325 7371325 coexp-gc thin 500000 20000 collections : 19230 19230 0 0 storage: - 0 15 144 regions: - 0 7371325 7371325 # -- The code -- procedure main(arglist) if *arglist ~= 3 then usage("Wrong number of arguments.") case wt := get(arglist) of { "fat": gcp := fatgcp default: gcp := thingcp } n := integer(get(arglist)) | usage("itterations") w := integer(get(arglist)) | usage("words-of-fat") write("coexp-gc ",wt," ",n," ",w) cx := gcp(w) every 1 to n do ^cx #every collect(1 to 3) every writes("collections : "|&collections) do writes(" ") ; write() every writes("storage: "|"-"|&storage) do writes(" ") ; write() every writes("regions: "|"-"|®ions) do writes(" ") ; write() write() end procedure usage(s) stop("usage: coexp-gc [fat|*] <iterations> <words-of-fat>" || if \s then "\n***"||s else "") end procedure fatgcp(n) local fat #fat := list(n) fat := "" every 1 to n do fat ||:= ?string(&ascii) return create n end procedure thingcp(n) return create n end ############ |