From d6f3c823aaf2ab5e9c383a09dddfb7f29cc712ba Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 3 Aug 2026 12:59:03 +0200 Subject: [PATCH 1/3] chore: Add script to show the sizes of futures (async Rust) --- scripts/future-sizes.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 scripts/future-sizes.sh diff --git a/scripts/future-sizes.sh b/scripts/future-sizes.sh new file mode 100755 index 0000000000..750f58f6a0 --- /dev/null +++ b/scripts/future-sizes.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Report the largest async-fn futures using rustc's unstable -Zprint-type-sizes. +# +# Usage: scripts/future-sizes.sh [TOP_N] (default: 30) +# +# Uses a dedicated target dir so the normal build cache is untouched +# and repeated runs only recompile the core crate itself. + +TOP_N="${1:-30}" + +export CARGO_TARGET_DIR="target/type-sizes" +export RUSTFLAGS="-Zprint-type-sizes" +export RUSTC_BOOTSTRAP=1 + +# Warm the dependency cache so their output doesn't pollute the report later. +cargo check -q --release -p deltachat + +# Recompile only the core crate (release) capture its type-size report. +cargo clean --release -p deltachat +report="$CARGO_TARGET_DIR/type-sizes.txt" +if ! cargo check --release -p deltachat >"$report"; then + tail -20 "$report" + exit 1 +fi + +sizes=$(rg '^print-type-size type: `\{async fn body of (.*)\(\)\}`: ([0-9]+) bytes' \ + -or '$2 $1' "$report" | sort -rn | uniq) +if [ -z "$sizes" ]; then + echo "error: no type-size output found, see $report" >&2 + exit 1 +fi + +echo "Largest async fn futures in deltachat (top $TOP_N, bytes):" +head -"$TOP_N" <<<"$sizes" + +echo +echo "Full report (all types, with per-field breakdown): $report" From 333c28609d16c2374270c8fe266f286e9b7b8f23 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 3 Aug 2026 15:44:05 +0200 Subject: [PATCH 2/3] When warming the dependency cache, print progress but no future sizes yet --- scripts/future-sizes.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/future-sizes.sh b/scripts/future-sizes.sh index 750f58f6a0..f153dee5cf 100755 --- a/scripts/future-sizes.sh +++ b/scripts/future-sizes.sh @@ -15,7 +15,7 @@ export RUSTFLAGS="-Zprint-type-sizes" export RUSTC_BOOTSTRAP=1 # Warm the dependency cache so their output doesn't pollute the report later. -cargo check -q --release -p deltachat +cargo check --release -p deltachat >/dev/null # Recompile only the core crate (release) capture its type-size report. cargo clean --release -p deltachat From 2971bb3e6d05129c862fbfde59c5029222082289 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 3 Aug 2026 15:50:34 +0200 Subject: [PATCH 3/3] Make sure Cargo.lock isn't changed --- scripts/future-sizes.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/future-sizes.sh b/scripts/future-sizes.sh index f153dee5cf..133d77db1f 100755 --- a/scripts/future-sizes.sh +++ b/scripts/future-sizes.sh @@ -15,12 +15,12 @@ export RUSTFLAGS="-Zprint-type-sizes" export RUSTC_BOOTSTRAP=1 # Warm the dependency cache so their output doesn't pollute the report later. -cargo check --release -p deltachat >/dev/null +cargo check --locked --release -p deltachat >/dev/null # Recompile only the core crate (release) capture its type-size report. -cargo clean --release -p deltachat +cargo clean --locked --release -p deltachat report="$CARGO_TARGET_DIR/type-sizes.txt" -if ! cargo check --release -p deltachat >"$report"; then +if ! cargo check --locked --release -p deltachat >"$report"; then tail -20 "$report" exit 1 fi