forked from oils-for-unix/oils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalloclog.sh
executable file
·93 lines (75 loc) · 2.16 KB
/
alloclog.sh
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
#!/usr/bin/env bash
#
# Usage:
# benchmarks/sizelog.sh <function name>
#
# Example:
# ninja _test/osh_eval.alloclog
# benchmarks/alloclog.sh alloc-hist
set -o nounset
set -o pipefail
set -o errexit
source benchmarks/common.sh
# ~191K total allocations for configure
# ~2.1M for abuild
# ~15.7M for benchmarks/testdata/configure
# ~42.8M for benchmarks/testdata/configure-coreutils
alloc-hist() {
local prog=${1:-configure}
_bin/osh_eval.alloclog -n $prog | egrep '^new|^malloc' | hist
#_bin/osh_eval.sizelog -n $prog | egrep '^new|^malloc' | hist
}
list-lengths() {
### Show the address of each list, its length, and its maximum element
local prog=${1:-configure}
_bin/osh_eval.alloclog -n $prog | egrep '^0x' | benchmarks/alloclog.py
}
# Hm this shows that almost all lists have 1-3 elements.
# Are these the spid lists?
#
# Should we then do small size optimization?
# TODO: Where are they allocated from? Can uftrace answer that?
#
# count listlength
# 734 6
# 1835 5
# 10718 4
# 66861 2
# 67841 3
# 179893 1
#
# 329628 _tmp/lists.txt
length-hist() {
list-lengths "$@" | awk '{print $2}' > _tmp/lists.txt
cat _tmp/lists.txt | hist
wc -l _tmp/lists.txt
}
build-variants() {
# opt uses dumb_alloc
# TODO: might want _bin/cxx-tcmalloc/osh_eval, which depends on a system library
ninja _bin/cxx-{opt,malloc}.osh_eval
}
time-mem() {
local out=$1
local prefix=$2
shift 2
/usr/bin/time -o $out --append --format "$prefix\\t%U\\t%M" -- "$@" >/dev/null
}
measure() {
local out=_tmp/alloclog.tsv
rm -f $out
for variant in .opt .malloc .tcmalloc; do
echo $variant
#time-mem _bin/osh_eval$variant -c 'echo hi'
# dumb_alloc: 3876 KiB, GNU: 4088, tcmalloc: 9200.
# OK that's actually not too bad for GNU. Not too much overhead.
#local file=configure
# dumb_alloc: 77460, GNU: 93976, tcmalloc: 70732
# Gah that is not good. I want to get these numbers down.
local file=benchmarks/testdata/configure-coreutils
time-mem $out "$variant\\tparse" _bin/osh_eval$variant --ast-format none -n $file
time-mem $out "$variant\\trun" _bin/osh_eval$variant benchmarks/compute/fib.sh 1000 44
done
cat $out
}
"$@"