Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.
Rust desktop-appdiscorddiscord-clienteguielectron-alternativelightweightlinuxmacosnative-apprustwindows
Linux CI: measure the build's memory
VRonGitHub93a39360cd04
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.ymlindex 01eb2a6..792797e 100644--- a/.github/workflows/linux.yml+++ b/.github/workflows/linux.yml@@ -46,6 +46,15 @@ jobs:- name: Packagerun: sh packaging/linux/package.sh+ - name: Memory check+ # How much RAM the build holds on Linux (the demo on a virtual screen,+ # sampled for 75 s), in the run's summary. For information only: it+ # never fails the build.+ continue-on-error: true+ run: |+ sudo apt-get install -y --no-install-recommends xvfb libgl1-mesa-dri libglx-mesa0 libegl-mesa0+ sh packaging/linux/memory-check.sh target/release/rustcord 75+- uses: actions/upload-artifact@v7with:name: rustcord-linux-x86_64diff --git a/packaging/linux/memory-check.sh b/packaging/linux/memory-check.shnew file mode 100755index 0000000..039e2f7--- /dev/null+++ b/packaging/linux/memory-check.sh@@ -0,0 +1,97 @@+#!/bin/sh+# Measures what RustCord holds in memory on Linux, counted the way system+# monitors count it. Starts the demo (no account, no network, a fresh+# config) on a virtual X screen, samples /proc while it settles, then lists+# the mappings that hold the most. Run from the repository root after+# `cargo build --release -p rustcord`; needs Xvfb and Mesa (CI installs+# them). On GitHub Actions the figures also go to the run's summary.+#+# Without a graphics card Mesa draws on the processor (llvmpipe), so the+# renderer's pictures and compiled shaders sit in RustCord's own memory:+# compare these runs with each other, not with a desktop's figures.+#+# Usage: memory-check.sh [path to rustcord] [seconds to watch]+set -eu++exe="${1:-target/release/rustcord}"+secs="${2:-75}"++home=$(mktemp -d)+Xvfb :99 -screen 0 1280x800x24 -nolisten tcp >/dev/null 2>&1 &+xvfb=$!+pid=""+trap 'kill $pid "$xvfb" 2>/dev/null || true; rm -rf "$home"' EXIT+sleep 2++DISPLAY=:99 HOME="$home" XDG_CONFIG_HOME="$home/.config" XDG_CACHE_HOME="$home/.cache" \+ XDG_DATA_HOME="$home/.local/share" RUSTCORD_PERF=1 \+ "$exe" --demo >"$home/output.txt" 2>&1 &+pid=$!++# A /proc figure in kB (0 when missing).+kb() {+ awk -v key="$1:" '$1 == key { print $2; found = 1 } END { if (!found) print 0 }' "/proc/$pid/$2"+}+mb() {+ echo $(( ($1 + 512) / 1024 ))+}++summary="${GITHUB_STEP_SUMMARY:-/dev/null}"+{+ echo "### RustCord memory on Linux (demo, software rendering)"+ echo+ echo "| after | in RAM (RSS) | private (anon) | private (USS) | proportional (PSS) | files | peak RSS | threads |"+ echo "|---:|---:|---:|---:|---:|---:|---:|---:|"+} >>"$summary"+printf '%6s %8s %8s %8s %8s %8s %9s %8s\n' "after" "RSS" "anon" "USS" "PSS" "files" "peak RSS" "threads"++waited=0+for at in 5 10 20 30 45 60 75 90 120; do+ [ "$at" -le "$secs" ] || break+ sleep $((at - waited))+ waited=$at+ if ! kill -0 "$pid" 2>/dev/null; then+ echo "RustCord exited before ${at} s; its output:"+ tail -n 40 "$home/output.txt"+ exit 1+ fi+ rss=$(kb VmRSS status)+ anon=$(kb RssAnon status)+ files=$(kb RssFile status)+ peak=$(kb VmHWM status)+ threads=$(kb Threads status)+ pss=$(kb Pss smaps_rollup)+ uss=$(( $(kb Private_Clean smaps_rollup) + $(kb Private_Dirty smaps_rollup) ))+ printf '%5ss %5s MB %5s MB %5s MB %5s MB %5s MB %6s MB %8s\n' "$at" "$(mb "$rss")" "$(mb "$anon")" "$(mb "$uss")" "$(mb "$pss")" "$(mb "$files")" "$(mb "$peak")" "$threads"+ echo "| $at s | $(mb "$rss") MB | $(mb "$anon") MB | $(mb "$uss") MB | $(mb "$pss") MB | $(mb "$files") MB | $(mb "$peak") MB | $threads |" >>"$summary"+done++# Where it is: each mapping's file (or [heap], [anon]…) with what of it is in+# RAM and how much of that is private, written memory ("anon": the heap, and+# the pages of libraries that loading them changed).+echo+echo "Biggest mappings (kB in RAM, of which anon):"+mappings=$(awk '+ /^[0-9a-f]+-[0-9a-f]+ / { name = ($6 == "") ? "[anon]" : $6; n = split(name, part, "/"); name = part[n]; next }+ /^Rss:/ { rss[name] += $2 }+ /^Anonymous:/ { anon[name] += $2 }+ END { for (k in rss) if (rss[k] > 0) printf "%9d %9d %s\n", rss[k], anon[k], k }+' "/proc/$pid/smaps" | sort -rn | head -n 25)+echo "$mappings"+{+ echo+ echo "<details><summary>Biggest mappings (kB in RAM, of which anon)</summary>"+ echo+ echo '```'+ echo "$mappings"+ echo '```'+ echo "</details>"+} >>"$summary"++# RustCord's own view: the glyph atlas, image caches and allocator figures.+log=$(find "$home" -name 'rustcord*.log' | head -n 1)+if [ -n "$log" ]; then+ echo+ echo "RustCord's log:"+ grep -E 'startup:|perf:|memory:|linux:|fonts:' "$log" | sed -e 's/per frame: [^;]*; //' | tail -n 12+fi