| 1 |
#! /usr/bin/crm |
| 2 |
# |
| 3 |
# match_isolate_reclaim.crm - test match/isolate memory reclamation |
| 4 |
|
| 5 |
# Copyright 2009 William S. Yerazunis. |
| 6 |
# This file is under GPLv3, as described in COPYING. |
| 7 |
|
| 8 |
{ |
| 9 |
window |
| 10 |
output /\nMatch-Isolate reclamation test. If this program doesn't \n/ |
| 11 |
output /error out, the test is passed. (we allocate about 80 megs, \n/ |
| 12 |
output /well past the window size, but in small (400K) chunks that\n/ |
| 13 |
output /alternately are allocated and become reclaimable) \n/ |
| 14 |
|
| 15 |
alter (:_dw:) /foo/ |
| 16 |
isolate (:bytes: :s:) |
| 17 |
syscall () (:bytes:) /cat \/usr\/share\/dict\/words/ |
| 18 |
eval (:s:) /:#:bytes:/ |
| 19 |
isolate (:startbytes:) // |
| 20 |
isolate (:endbytes:) // |
| 21 |
isolate (:passes:) /0/ |
| 22 |
isolate (:flux:) /0/ |
| 23 |
isolate (:dflux:) /0/ |
| 24 |
isolate (:b2: :b3:) |
| 25 |
isolate (:ihead:) /X/ |
| 26 |
|
| 27 |
eval (:startbytes:) /:#:_iso:/ |
| 28 |
output /OK_IF_SIZE_CHANGES: Size of isolation at start: :*:startbytes:\n/ |
| 29 |
|
| 30 |
{ |
| 31 |
isolate (:b2:) /:*:bytes:/ |
| 32 |
match (:b3:) /.*/ [:b2:] |
| 33 |
eval (:flux:) /:@: :*:flux: + :#:b2::/ |
| 34 |
match (:bytes:) /./ |
| 35 |
isolate (:bytes:) /:*:b2:/ |
| 36 |
eval (:flux:) /:@: :*:flux: + :#:bytes::/ |
| 37 |
match (:b2:) /./ |
| 38 |
eval (:passes:) /:@: :*:passes: + 1 :/ |
| 39 |
# how many passes should we run? |
| 40 |
eval /:@: :*:passes: < 10 :/ |
| 41 |
liaf |
| 42 |
} |
| 43 |
|
| 44 |
match (:b3:) /./ |
| 45 |
eval (:endbytes:) /:#:_iso:/ |
| 46 |
|
| 47 |
output /Bytes used per pass: :*:s:\n/ |
| 48 |
output /Passes done: :*:passes: \n/ |
| 49 |
output /Total flux through isolation: :*:flux:\n/ |
| 50 |
output /OK_IF_SIZE_CHANGES: Final isolation size: :*:endbytes: \n/ |
| 51 |
eval (:dflux:) /:@: :*:endbytes: - :*:startbytes::/ |
| 52 |
output /OK_IF_LESS_THAN_10: Total growth: :*:dflux:\n/ |
| 53 |
match [:_iso: 0 1000] (:ihead:) /.*/ |
| 54 |
# output /HEAD: :*:ihead:\n/ |
| 55 |
match (:ihead:) /./ |
| 56 |
{ |
| 57 |
isolate (:b2:) /:*:bytes:/ |
| 58 |
match (:b3:) /.*/ [:b2:] |
| 59 |
eval (:flux:) /:@: :*:flux: + :#:b2::/ |
| 60 |
match (:bytes:) /./ |
| 61 |
isolate (:bytes:) /:*:b2:/ |
| 62 |
eval (:flux:) /:@: :*:flux: + :#:bytes::/ |
| 63 |
match (:b2:) /./ |
| 64 |
eval (:passes:) /:@: :*:passes: + 1 :/ |
| 65 |
# how many passes should we run? |
| 66 |
eval /:@: :*:passes: < 20 :/ |
| 67 |
liaf |
| 68 |
} |
| 69 |
|
| 70 |
match (:b3:) /./ |
| 71 |
eval (:endbytes:) /:#:_iso:/ |
| 72 |
|
| 73 |
output /Bytes used per pass: :*:s:\n/ |
| 74 |
output /Passes done: :*:passes: \n/ |
| 75 |
output /Total flux through isolation: :*:flux:\n/ |
| 76 |
output /OK_IF_SIZE_CHANGES: Final isolation size: :*:endbytes: \n/ |
| 77 |
eval (:dflux:) /:@: :*:endbytes: - :*:startbytes::/ |
| 78 |
output /OK_IF_LESS_THAN_20: Total growth: :*:dflux:\n/ |
| 79 |
match [:_iso: 0 1000] (:ihead:) /.*/ |
| 80 |
# output /HEAD: :*:ihead:\n/ |
| 81 |
match (:ihead:) /./ |
| 82 |
{ |
| 83 |
isolate (:b2:) /:*:bytes:/ |
| 84 |
match (:b3:) /.*/ [:b2:] |
| 85 |
eval (:flux:) /:@: :*:flux: + :#:b2::/ |
| 86 |
match (:bytes:) /./ |
| 87 |
isolate (:bytes:) /:*:b2:/ |
| 88 |
eval (:flux:) /:@: :*:flux: + :#:bytes::/ |
| 89 |
match (:b2:) /./ |
| 90 |
eval (:passes:) /:@: :*:passes: + 1 :/ |
| 91 |
# how many passes should we run? |
| 92 |
eval /:@: :*:passes: < 30 :/ |
| 93 |
liaf |
| 94 |
} |
| 95 |
|
| 96 |
match (:b3:) /./ |
| 97 |
eval (:endbytes:) /:#:_iso:/ |
| 98 |
|
| 99 |
output /Bytes used per pass: :*:s:\n/ |
| 100 |
output /Passes done: :*:passes: \n/ |
| 101 |
output /Total flux through isolation: :*:flux:\n/ |
| 102 |
output /OK_IF_SIZE_CHANGES: Final isolation size: :*:endbytes: \n/ |
| 103 |
eval (:dflux:) /:@: :*:endbytes: - :*:startbytes::/ |
| 104 |
output /OK_IF_LESS_THAN_30: Total growth: :*:dflux:\n/ |
| 105 |
match [:_iso: 0 1000] (:ihead:) /.*/ |
| 106 |
# output /HEAD: :*:ihead:\n/ |
| 107 |
match (:ihead:) /./ |
| 108 |
{ |
| 109 |
isolate (:b2:) /:*:bytes:/ |
| 110 |
match (:b3:) /.*/ [:b2:] |
| 111 |
eval (:flux:) /:@: :*:flux: + :#:b2::/ |
| 112 |
match (:bytes:) /./ |
| 113 |
isolate (:bytes:) /:*:b2:/ |
| 114 |
eval (:flux:) /:@: :*:flux: + :#:bytes::/ |
| 115 |
match (:b2:) /./ |
| 116 |
eval (:passes:) /:@: :*:passes: + 1 :/ |
| 117 |
# how many passes should we run? |
| 118 |
eval /:@: :*:passes: < 40 :/ |
| 119 |
liaf |
| 120 |
} |
| 121 |
|
| 122 |
match (:b3:) /./ |
| 123 |
eval (:endbytes:) /:#:_iso:/ |
| 124 |
|
| 125 |
output /Bytes used per pass: :*:s:\n/ |
| 126 |
output /Passes done: :*:passes: \n/ |
| 127 |
output /Total flux through isolation: :*:flux:\n/ |
| 128 |
output /OK_IF_SIZE_CHANGES: Final isolation size: :*:endbytes: \n/ |
| 129 |
eval (:flux:) /:@: :*:endbytes: - :*:startbytes::/ |
| 130 |
output /OK_IF_LESS_THAN_40: Total growth: :*:flux:\n/ |
| 131 |
match [:_iso: 0 1000] (:ihead:) /.*/ |
| 132 |
# output /HEAD: :*:ihead:\n/ |
| 133 |
match (:ihead:) /./ |
| 134 |
} |