Skip to content

Commit

Permalink
Quick and dirty visualization of the memory usage
Browse files Browse the repository at this point in the history
Alsok, building all the code into separate folders.. does this make a difference... no, doesn't look like it.
  • Loading branch information
rolandbosa authored and hummeltech committed Jun 29, 2024
1 parent 6995d7b commit 6379979
Show file tree
Hide file tree
Showing 5 changed files with 981 additions and 913 deletions.
43 changes: 23 additions & 20 deletions measure_rss_anon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,48 @@ function runtest() {
# Measure the startup memory usage (RssAnon) of process 'renderd' for 30 seconds,
# then issue a render_list command and keep on monitoring for 4.5 more minutes.
if [ -z "$1" ]; then
echo "Supply argument to tag series"
exit 1
echo "Supply argument to tag series"
exit 1
fi

BUILD=build/$1
mkdir -p $BUILD

echo "Configuring..."
cmake -B build -DMALLOC_LIB=$1 .
cmake -B $BUILD -DMALLOC_LIB=$1 .

echo "Building..."
cmake --build build
cmake --build $BUILD

# Store the results in this file
JSON=rssanon-$1.json5

echo "Libraries:"
ldd ./build/src/renderd | grep 'glib\|alloc'
ldd ./$BUILD/src/renderd | grep 'glib\|alloc'

echo "Starting renderd..."
./build/src/renderd -f -c /etc/renderd.conf &
./$BUILD/src/renderd -f -c /etc/renderd.conf &

SECONDS=0
printf '[\n' >$JSON
printf 'const %s = [\n' $1 >$JSON
while [ $SECONDS -lt 30 ]
do
RSS=$(grep RssAnon /proc/$(pidof renderd)/status | awk '{print $2}')
printf '{ "t": %d, "tag": "%s", "rss": %d },\n' $SECONDS $1 $RSS >>$JSON
printf 'Time:%d Mem:%d\n' $SECONDS $RSS
sleep 1
RSS=$(grep RssAnon /proc/$(pidof renderd)/status | awk '{print $2}')
printf '{ "t": %d, "tag": "%s", "rss": %d },\n' $SECONDS $1 $RSS >>$JSON
printf 'Time:%d Mem:%d\n' $SECONDS $RSS
sleep 1
done

echo "Issuing render request..."
./build/src/render_list -c /etc/renderd.conf -n 8 --all --force --map=retina -z 6 -Z 6 &
./$BUILD/src/render_list -c /etc/renderd.conf -n 8 --all --force --map=retina -z 6 -Z 6 &
while [ $SECONDS -lt 300 ]
do
RSS=$(grep RssAnon /proc/$(pidof renderd)/status | awk '{print $2}')
printf '{ "t": %d, "tag": "%s", "rss": %d },\n' $SECONDS $1 $RSS >>$JSON
printf 'Time:%d Mem:%d\n' $SECONDS $RSS
sleep 1
RSS=$(grep RssAnon /proc/$(pidof renderd)/status | awk '{print $2}')
printf '{ "t": %d, "tag": "%s", "rss": %d },\n' $SECONDS $1 $RSS >>$JSON
printf 'Time:%d Mem:%d\n' $SECONDS $RSS
sleep 1
done
printf ']\n' >>$JSON
printf '{"t": %d, "tag": "%s", "rss": %d }];\n' $SECONDS $1 $RSS >>$JSON

echo "Measurement completed. Results are here: $JSON"
kill $(pidof renderd)
Expand Down
65 changes: 65 additions & 0 deletions rss_anon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<html>

<head>
<title>
Memory comparison of renderd with various malloc libraries
</title>
</head>

<body>
<div>
<canvas id="myChart"></canvas>
</div>

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

<script src="file:rssanon-glib.json5"></script>
<script src="file:rssanon-jemalloc.json5"></script>
<script src="file:rssanon-tcmalloc.json5"></script>

<script>
/* yes, this will yield O(n^2), but I can't be bothered right now */
const rss = (time, data) => {
let rss = 0;
data.forEach(e => {
if (e.t < time) {
rss = e.rss;
}
});
return rss;
}
const ctx = document.getElementById('myChart');
const data = glib.map(x => ({
t: x.t,
glib_rss: x.rss,
je_rss: rss(x.t, jemalloc),
tc_rss: rss(x.t, tcmalloc)
}));
new Chart(ctx, {
type: 'line',
data: {
labels: data.map(x => x.t),
datasets: [{
label: 'glib',
data: data.map(x => x.glib_rss)
}, {
label: 'jemalloc',
data: data.map(x => x.je_rss)
}, {
label: 'tcmalloc',
data: data.map(x => x.tc_rss)
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
</script>

</body>

</html>
Loading

0 comments on commit 6379979

Please sign in to comment.