-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgc.es
More file actions
129 lines (124 loc) · 3.68 KB
/
Copy pathgc.es
File metadata and controls
129 lines (124 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env es
fn %gcstats args {
local (
freemem=; usedmem=; nobjects=;
ngcs=; type=;
) {
match <={$&gcstats} (
(old) {
type = $matchexpr(1)
freemem = $matchexpr(2)
usedmem = $matchexpr(3)
nobjects = $matchexpr(4)
ngcs = $matchexpr(6)
}
(new generational) {
type = $matchexpr(1)
freemem = $matchexpr(2)
usedmem = $matchexpr(4)
nobjects= $matchexpr(9)
ngcs = $matchexpr(11)
}
* { unreachable }
)
if {~ $args -v} {
echo 'type = '^$type
echo 'freemem = '^$freemem
echo 'usedmem = '^$usedmem
echo 'objects = '^$nobjects
echo 'number of gcs = '^$ngcs
}
result $type $freemem $usedmem $nobjects $ngcs
}
}
fn %gc {
$&collect
result ()
}
fn %gcinfo {
match <={$&gcstats} (
(old) {
echo 'type =' $matchexpr(1)
echo 'freemem =' $matchexpr(2) '('^<={div $matchexpr(2) 1024} 'kb)'
echo 'usedmem =' $matchexpr(3) '('^<={div $matchexpr(3) 1024} 'kb)'
echo 'objects =' $matchexpr(4)
echo 'allocations =' $matchexpr(5)
echo 'number of gcs =' $matchexpr(6)
echo 'gcblocked =' $matchexpr(7)
}
(new generational) {
echo 'type =' $matchexpr(1)
echo 'freemem (total) =' $matchexpr(2) '('^<={div $matchexpr(2) 1024} 'kb)'
echo 'freemem (real) =' $matchexpr(3) '('^<={div $matchexpr(3) 1024} 'kb)'
echo 'usedmem (total) =' $matchexpr(4) '('^<={div $matchexpr(4) 1024} 'kb)'
echo 'usedmem (real) =' $matchexpr(5) '('^<={div $matchexpr(5) 1024} 'kb)'
echo 'free blocks =' $matchexpr(6)
echo 'used blocks =' $matchexpr(7)
if {~ $matchexpr(1) generational} {
echo 'old blocks =' $matchexpr(21)
}
echo 'number of frees =' $matchexpr(8)
echo 'number of allocs =' $matchexpr(9)
echo 'allocations =' $matchexpr(10)
echo 'number of gcs =' $matchexpr(11)
echo 'sort_after_n =' $matchexpr(12)
echo 'nsortgc =' $matchexpr(13)
echo 'coalesce_after =' $matchexpr(14)
echo 'ncoalescegc =' $matchexpr(15)
echo 'gc_after =' $matchexpr(16)
echo 'nregions =' $matchexpr(17)
echo 'nsort =' $matchexpr(18)
echo 'ncoalesce =' $matchexpr(19)
echo 'blocksize =' $matchexpr(20)
echo 'sorting type =' $matchexpr(24)
echo 'gcblocked =' $matchexpr(25)
if {~ $matchexpr(1) generational} {
echo 'oldage =' $matchexpr(22)
echo 'oldsweep_after =' $matchexpr(23)
}
if {~ $1 -v || ~ $1 -r} {
if {gt $matchexpr(17) 100} {
echo >[1=2] 'error: not printing regions: more than 100 regions allocated'
return <=true
}
%gc
for ((p r) = <={$&dumpregions}; n = <={%range 1 $matchexpr(17)}) {
echo ' '^$n^' region '^$p^': '^$r^' ('^<={div $r 1024 |> @{div $1 1024}}^' megabytes)'
}
}
}
* { unreachable }
)
}
fn __es_initgc {
matchall <={$&gcstats |> %first} (
(new generational) {
gc_after = ''
set-gc_after = @ v { $&gctuning gcafter $v }
get-gc_after = @{ $&gctuning |> %elem 1 }
gc_sortaftern = ''
set-gc_sortaftern = @ v { $&gctuning sortaftern $v }
get-gc_sortaftern = @{ $&gctuning |> %elem 2 }
gc_coalesceaftern = ''
set-gc_coalesceaftern = @ v { $&gctuning coalesceaftern $v }
get-gc_coalesceaftern = @{ $&gctuning |> %elem 3 }
noexport = $noexport (
gc_after set-gc_after get-gc_after
gc_sortaftern get-gc_sortaftern set-gc_sortaftern
gc_coalesceaftern get-gc_coalesceaftern set-gc_coalesceaftern
)
}
generational {
gc_oldage = ''
set-gc_oldage = @ v { $&gctuning oldage $v }
get-gc_oldage = @{ $&gctuning |> %elem 4 }
gc_oldsweepafter = ''
set-gc_oldsweepafter = @ v { $&gctuning oldsweepafter $v }
get-gc_oldsweepafter = @{ $&gctuning |> %elem 5 }
noexport = $noexport (
gc_oldage set-gc_oldage get-gc_oldage
gc_oldsweepafter set-gc_oldsweepafter get-gc_oldsweepafter
)
}
)
}