Skip to content

Commit ad7f539

Browse files
leftwoAlan Hanson
andauthored
Update test mem to also show physical space used by regions. (#1724)
Made the test_mem.sh test also calculate and display how much space is consumed by the region directories after a region has been used. Updated the buildomat job to test and display results for both 4k and 512b block sizes with typical omicron region sizes. Example output: ``` alan@atrium:crucible$ ./tools/test_mem.sh -b 4096 -e 16384 -c 1600 Using block size 4096 Using extent size 16384 Using extent count 1600 /home/alan/ws/crucible Memory usage test begins at May 29, 2025 at 07:06:47 PM UTC Memory usage values in kilobytes unless specified otherwise Region with ES:16384 EC:1600 BS:4096 Size: 100 GiB Extent Size: 64 MiB PID RSS RSS/EC VSZ VSZ/EC HEAP HEAP/EC TOTAL TOTAL/EC EC 10287 118140 73 149984 93 95124 59 149984 93 1600 10286 120240 75 152080 95 97244 60 152080 95 1600 10288 119068 74 150908 94 96088 60 150908 94 1600 Region:100 GiB Extent:64 MiB Total downstairs (pmap -x): 442 MiB Size of volume user gets : 107374182400 Size on disk of all region dirs: 329682283958 or 307G Size on disk of a single region: 109894094651 or 102G Total Overage with 4096 block size: 307.04% Region Overage with 4096 block size: 102.35% Memory usage test finished on May 29, 2025 at 07:08:40 PM UTC ``` Co-authored-by: Alan Hanson <alan@oxide.computer>
1 parent 99778b3 commit ad7f539

File tree

2 files changed

+56
-22
lines changed

2 files changed

+56
-22
lines changed

.github/buildomat/jobs/test-memory.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@ vmstat -T d -p 1 < /dev/null > /tmp/debug/paging.txt 2>&1 &
5959
pfexec dtrace -Z -s $input/scripts/perf-downstairs-tick.d > /tmp/debug/perf.txt 2>&1 &
6060
pfexec dtrace -Z -s $input/scripts/upstairs_info.d > /tmp/debug/upinfo.txt 2>&1 &
6161

62-
banner memtest
63-
ptime -m bash $input/scripts/test_mem.sh
62+
banner 512-memtest
63+
ptime -m bash $input/scripts/test_mem.sh -b 512 -e 131072 -c 160
64+
banner 4k-memtest
65+
ptime -m bash $input/scripts/test_mem.sh -b 4096 -e 16384 -c 160

tools/test_mem.sh

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
22

3-
# Memory usage test shell script.
4-
3+
# Memory and space usage test shell script.
54
set -o errexit
65
set -o pipefail
76

@@ -17,19 +16,35 @@ function ctrl_c() {
1716

1817
usage () {
1918
echo "Usage: $0 [f] [-b #] [-g <PATH>]" >&2
20-
echo " -b block_size Block size for the region (default 4096)" >&2
19+
echo " -b block_size Block size for the region (default 4096)" >&2
20+
echo " -c extent count Number of extent files (default 160)" >&2
21+
echo " -e extent size Size of an extent file (default 16384)" >&2
2122
echo " -g REGION_DIR Directory where regions will be created" >&2
2223
echo " (default /var/tmp/dsc)" >&2
24+
echo ""
25+
echo " 10GiB 4k region in omicron: -b 4096 -e 16384 -c 160"
26+
echo " 10GiB 512 region in omicron: -b 512 -e 131072 -c 160"
2327
}
2428

2529
block_size=4096
30+
# Omicron default for 512 byte block size
31+
# extent_size=131072
32+
# Omicron default for 4k block size
33+
extent_size=16384
34+
extent_count=160
2635
region_dir="/var/tmp/dsc"
2736

28-
while getopts 'b:g:h' opt; do
37+
while getopts 'b:c:e:g:h' opt; do
2938
case "$opt" in
3039
b) block_size=$OPTARG
3140
echo "Using block size $block_size"
3241
;;
42+
c) extent_count=$OPTARG
43+
echo "Using extent count $extent_count"
44+
;;
45+
e) extent_size=$OPTARG
46+
echo "Using extent size $extent_size"
47+
;;
3348
g) region_dir=$OPTARG
3449
echo "Using region dir of $region_dir"
3550
;;
@@ -84,21 +99,23 @@ function show_mem_summary() {
8499
WORK_ROOT=${WORK_ROOT:-/tmp}
85100
mkdir -p "$WORK_ROOT"
86101
test_mem_log="$WORK_ROOT/test_mem_log.txt"
87-
# Create a region with the given extent_size ($1) and extent_count ($2)
102+
# Create a region with the given extent_size ($1), extent_count ($2), and
103+
# block_size ($3)
88104
# Once created, write to every block in the region, then display memory usage.
89105
function mem_test() {
90-
if [[ $# -ne 2 ]]; then
91-
echo "Missing EC and ES for mem_test()" >&2
106+
if [[ $# -ne 3 ]]; then
107+
echo "Missing EC, ES, or block size for mem_test()" >&2
92108
exit 1
93109
fi
94110
es=$1
95111
ec=$2
112+
bs=$3
96113

97-
total_size=$(echo "$es * $ec * $block_size" | bc)
114+
total_size=$(echo "$es * $ec * $bs" | bc)
98115
size_mib=$(echo "$total_size / 1024 / 1024" | bc)
99116
size_gib=$(echo "$size_mib / 1024" | bc)
100117

101-
echo -n "Region with ES:$es EC:$ec BS:$block_size "
118+
echo -n "Region with ES:$es EC:$ec BS:$bs "
102119
if [[ "$size_gib" -gt 0 ]]; then
103120
reported_size="$size_gib GiB"
104121
elif [[ "$size_mib" -gt 0 ]]; then
@@ -108,7 +125,7 @@ function mem_test() {
108125
fi
109126
echo -n "Size: $reported_size "
110127

111-
each_extent=$(echo "$es * $block_size" | bc)
128+
each_extent=$(echo "$es * $bs" | bc)
112129
each_extent_mib=$(echo "$each_extent / 1024 / 1024" | bc)
113130
if [[ "$each_extent_mib" -gt 0 ]]; then
114131
reported_extent_size="$each_extent_mib MiB"
@@ -120,7 +137,7 @@ function mem_test() {
120137

121138
"$dsc" create --ds-bin "$downstairs" --cleanup \
122139
--extent-size "$es" --extent-count "$ec" \
123-
--region-dir "$region_dir" --block-size "$block_size" \
140+
--region-dir "$region_dir" --block-size "$bs" \
124141
> "$test_mem_log" 2>&1
125142

126143
"$dsc" start --ds-bin "$downstairs" --region-dir "$region_dir" \
@@ -139,10 +156,16 @@ function mem_test() {
139156
# Args for crutest. Using the default IP:port for dsc
140157
args="-t 127.0.0.1:8810 -t 127.0.0.1:8820 -t 127.0.0.1:8830 -q"
141158

142-
# Fill the region
143-
echo "$ct" fill $args --skip-verify -g 1 >> "$test_mem_log" 2>&1
144-
"$ct" fill $args --skip-verify -g 1 >> "$test_mem_log" 2>&1
159+
# Fill the volume
160+
gen=1
161+
echo "$ct" fill $args --skip-verify -g $gen >> "$test_mem_log" 2>&1
162+
"$ct" fill $args --skip-verify -g $gen >> "$test_mem_log" 2>&1
163+
164+
# Add another 50k IOs to the volume
165+
((gen+=1))
166+
"$ct" generic $args -c 50000 -g $gen >> "$test_mem_log" 2>&1
145167

168+
# Display memory usage
146169
show_mem_summary "$ec"
147170
echo -n "Region:$reported_size Extent:$reported_extent_size "
148171
total_downstairs_mib=$(echo "$total_downstairs / 1024" | bc)
@@ -153,10 +176,22 @@ function mem_test() {
153176
fi
154177
echo "Total downstairs (pmap -x): $reported_downstairs"
155178

179+
# Display physical storage usage
156180
region_summary=$(du -sAh "$region_dir" | awk '{print $1}')
157181
region_size=$(du -sA "$region_dir" | awk '{print $1}')
158-
echo "Size on disk of all region dirs: $region_summary or $region_size"
159-
182+
region_0_size=$(du -sA "$region_dir"/8810 | awk '{print $1}')
183+
region_0_summary=$(du -sAh "$region_dir"/8810 | awk '{print $1}')
184+
echo "Size of volume user gets : $total_size"
185+
echo "Size on disk of all region dirs: $region_size or $region_summary"
186+
echo "Size on disk of a single region: $region_0_size or $region_0_summary"
187+
echo "$region_size $total_size $block_size" | awk '{ \
188+
percent = ($1 / $2) * 100; \
189+
printf " Total Overage with %d block size: %6.2f%%\n", $3, percent \
190+
}'
191+
echo "$region_0_size $total_size $block_size" | awk '{ \
192+
percent = ($1 / $2) * 100; \
193+
printf "Region Overage with %d block size: %6.2f%%\n", $3, percent \
194+
}'
160195
set +o errexit
161196
"$dsc" cmd shutdown >> "$test_mem_log" 2>&1
162197
wait $dsc_pid
@@ -191,9 +226,6 @@ fi
191226
echo "Memory usage test begins at $(date)"
192227
echo "Memory usage values in kilobytes unless specified otherwise"
193228

194-
# ES EC
195-
mem_test 16384 16
196-
mem_test 16384 160
197-
mem_test 16384 1600
229+
mem_test $extent_size $extent_count $block_size
198230

199231
echo "Memory usage test finished on $(date)"

0 commit comments

Comments
 (0)