home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / function / 1454 < prev    next >
Encoding:
Text File  |  1992-12-14  |  3.2 KB  |  93 lines

  1. Newsgroups: comp.lang.functional
  2. Path: sparky!uunet!enterpoop.mit.edu!ira.uka.de!math.fu-berlin.de!doerr
  3. From: doerr@inf.fu-berlin.de (Heiko Doerr)
  4. Subject: Q: garbage collection in Miranda
  5. Message-ID: <AOT9CLP@math.fu-berlin.de>
  6. Keywords: garbage collection Miranda
  7. Sender: news@math.fu-berlin.de (Math Department)
  8. Organization: Free University of Berlin, Germany
  9. Date: Mon, 14 Dec 1992 18:45:41 GMT
  10. Lines: 81
  11.  
  12.  
  13. While looking for data structures to store states of a computation
  14. the following questions arose concerning the garbage collector of
  15. Miranda. 
  16.  
  17. 1) Where is the implementation difference between list comprehensions
  18. and explicit recursive list definitions like the following? In an
  19. environment with heap size set to 10000 cells (this is small, I know),
  20. the lenght of the list defined by a comprehension cannot be evaluated.
  21.  
  22.     >list 0 = []
  23.     >list n = n : list (n-1)
  24.  
  25.     Miranda /heap 10000
  26.     heaplimit = 10000 cells
  27.     Miranda /count
  28.     Miranda #[1..50000]
  29.     <<not enough heap space -- task abandoned>>
  30.     ||reductions = 5548, cells claimed = 11094, no of gc's = 3, cpu = 0.32
  31.     Miranda #(list 50000)
  32.     50000
  33.     ||reductions = 400003, cells claimed = 417248, no of gc's = 51, cpu = 7.90
  34.     Miranda
  35.  
  36.  
  37. Looking to the garbage collection report (/gc) shows the different
  38. runtime behaviour of both implementations. In the first expression the
  39. number of collected cells drops one or more times but reaches 0 at
  40. some stage. The second implementation is more stable in that sense
  41. that in more runs the number of collected cells is around 9940.
  42.  
  43. But this leads to the second question.
  44.  
  45. 2) Is the garbage collector non-deterministic or can the following effect
  46. be predicted?
  47.  
  48. Once you evaluate the expressions "#(list 50000)" and "#[0..50000]"
  49. several times you will notice that the evaluation does not succeed all
  50. the times. Could anybody tell me whether and if so how the garbage
  51. collector is related to the operating system to explain this
  52. non-deterministic behaviour.
  53.  
  54. 3) Why does the extension of the heap changes the situation to the
  55. reverse effect?
  56.  
  57.     Miranda /heap 200000
  58.     heaplimit = 200000 cells
  59.     Miranda #[1..50000]
  60.     50000
  61.     ||reductions = 50004, cells claimed = 117248, no of gc's = 0, cpu = 1.88
  62.     Miranda #(list 50000)
  63.  
  64.     <<gc after 192248 claims>>
  65.  
  66.     <<gc after 83646 claims>>
  67.  
  68.     <<gc after 31371 claims>>
  69.  
  70.     <<gc after 11763 claims>>
  71.  
  72.     <<gc after 4413 claims>>
  73.     <<not enough heap space -- task abandoned>>
  74.     ||reductions = 297407, cells claimed = 314644, no of gc's = 4, cpu = 9.08
  75.     Miranda
  76.  
  77. Setting the heap to 200000 cells causes the successfull termination of
  78. the standard definition whereas the explicit definition causes heap
  79. overflow. 
  80.  
  81. These runs were executed on SUN-4 with 16 MB and Miranda version 2.014.
  82. Thanks to any hints on this questions.
  83.  
  84. Heiko
  85.  
  86. +-----------------------------------------------------------------+
  87. | Heiko Doerr                          Tel.: 030/896 91 106       |
  88. | Institut fuer Informatik             Fax.: 030/896 91 123       |
  89. | Freie Universitaet Berlin            e-mail:                    |
  90. | Nestorstrasse 8-9                      doerr@inf.fu-berlin.de   |
  91. | D-1000 Berlin 31                                                |
  92. +-----------------------------------------------------------------+
  93.