So, rust is slow to compile (see https://vfoley.xyz/rust-compile-speed-tips/ for some background) and I thought it’d be interesting to see if disk i/o made a big difference on a moderate project. Would writing to a RAM disk speed things up?
Quick answer – nope. Not at all.
The approach was to run this clean build and time it;
rm -rf target/* && time cargo build
For the disk runs, nothing clever – just as normal, with
target as standard directory on the SSD.
For the ram disk runs, I wrote a little script to prepare a ram disk – see this gist – and created a 6Gb ram disk to serve as the
target dir like so;
cd "$HOME/src/my-rust-project/workspaces" mv target target.disk create-ram-disk 6 "$HOME/src/my-rust-project/workspaces/target"
The summary – it’s no different. At all.
# Results DISK1: real 2m28.139s | user 22m20.473s | sys 1m49.867s DISK2: real 2m35.500s | user 23m7.738s | sys 1m55.345s RAM1: real 2m37.218s | user 22m43.319s | sys 1m53.874s RAM2: real 2m27.837s | user 22m58.143s | sys 1m56.239s
Well, maybe that saves you an afternoon of mucking about, or gives you enough info to waste some of your own time 🙂