Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hummeltech committed Jun 29, 2024
1 parent 16a95e0 commit eb2fe66
Show file tree
Hide file tree
Showing 14 changed files with 1,323 additions and 995 deletions.
52 changes: 24 additions & 28 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/src/renderd",
"args": ["-f", "-c", "/etc/renderd.conf"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/src/renderd",
"args": [
"-f",
"-c",
"/etc/renderd.conf"
],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
]
}
31 changes: 18 additions & 13 deletions measure_rss_anon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,60 @@ function runtest() {
mkdir -p $BUILD

echo "Configuring..."
cmake -B $BUILD -DMALLOC_LIB=$1 .
cmake -B $BUILD -DMALLOC_LIB=$1 -DENABLE_TESTS:BOOLEAN=ON .

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

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

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

mkdir -p ./$BUILD/tests/run/file ./$BUILD/tests/tiles/file

echo "Starting renderd..."
./$BUILD/src/renderd -f -c /etc/renderd.conf &
./$BUILD/src/renderd --config=$BUILD/tests/conf/file/renderd.conf --foreground &
RENDERD_PID=$!

SECONDS=0
printf 'const %s = [\n' $1 >$JSON
while [ $SECONDS -lt 30 ]
do
RSS=$(grep RssAnon /proc/$(pidof renderd)/status | awk '{print $2}')
RSS=$(grep RssAnon /proc/$RENDERD_PID/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 --all --config=$BUILD/tests/conf/file/renderd.conf --force --map=webp --max-load=$(($(nproc) * 2)) --max-zoom=10 &
while [ $SECONDS -lt 300 ]
do
RSS=$(grep RssAnon /proc/$(pidof renderd)/status | awk '{print $2}')
RSS=$(grep RssAnon /proc/$RENDERD_PID/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 '{"t": %d, "tag": "%s", "rss": %d }];\n' $SECONDS $1 $RSS >>$JSON

echo "Measurement completed. Results are here: $JSON. PID of renderd is: `pidof renderd`"
./$BUILD/src/render_list -c /etc/renderd.conf -S
#kill $(pidof renderd)
./$BUILD/src/render_list --config=$BUILD/tests/conf/file/renderd.conf --stop
#kill $RENDERD_PID
}

function compare_malloc() {
runtest glib
sleep 10
runtest jemalloc
sleep 10
runtest libc
sleep 10
runtest mimalloc
sleep 10
runtest tcmalloc
echo "Comparison completed."
}

# compare_malloc
compare_malloc

runtest jemalloc
# runtest jemalloc
113 changes: 59 additions & 54 deletions rss_anon.html
Original file line number Diff line number Diff line change
@@ -1,65 +1,70 @@
<html>
<head>
<title>Memory comparison of renderd with various malloc libraries</title>
</head>

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

<body>
<body>
<div>
<canvas id="myChart"></canvas>
<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 src="file:rssanon-libc.js"></script>
<script src="file:rssanon-jemalloc.js"></script>
<script src="file:rssanon-mimalloc.js"></script>
<script src="file:rssanon-tcmalloc.js"></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
}
}
}
/* 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 = libc.map((x) => ({
t: x.t,
libc_rss: x.rss,
je_rss: rss(x.t, jemalloc),
mi_rss: rss(x.t, mimalloc),
tc_rss: rss(x.t, tcmalloc),
}));
new Chart(ctx, {
type: "line",
data: {
labels: data.map((x) => x.t),
datasets: [
{
label: "libc",
data: data.map((x) => x.libc_rss),
},
{
label: "jemalloc",
data: data.map((x) => x.je_rss),
},
{
label: "mimalloc",
data: data.map((x) => x.mi_rss),
},
{
label: "tcmalloc",
data: data.map((x) => x.tc_rss),
},
],
},
options: {
scales: {
y: {
beginAtZero: true,
},
},
},
});
</script>

</body>

</html>
</body>
</html>
Loading

0 comments on commit eb2fe66

Please sign in to comment.