Did you try swapoff -a on your Raspi 400? Did it work remarkable faster oder did I suffer from imagination?
FW
Did you try swapoff -a on your Raspi 400? Did it work remarkable faster oder did I suffer from imagination?
FW
If you meant me; I did not.
Where would I put that ?
I meant everybody (who owns a 400).
In a commandline I did sudo swapoff -a and think my 400 is a little bit faster. Can be that my SD-card is very slow.
FW
try Free -h so see how much memory is used the amount of swap used on any of mi Pi's is negligible. my deductions from this are: If it is not being used then it cant be slowing the system down. It is probably not needed anyway.
this will probably vary depending on your own usage patterns
You can also see this information on the 'top' display along with other useful stuff about what process(es) are hogging memory and/or CPU time and how much memory is being occupied by file buffering (often more than is occupied by executable code).
If you aren't using much memory, it wont be any faster. If you are using too much memory swapping to an SD card will cause it to run very slowly, but not having any swap will cause it to hang while it attempts to kill off processes, or if you are unlucky hang altogether.
---druck
SD cards are quite slow, yes. If you need a lot of swap, then swap to a faster device. I used to have swap on a ZFS RAIDZ array spread across 4 × 2TB USB3 drives on a USB3 hub, and it seemed pretty fast to me.
On my older Pi 3 or Pi 3B, I configured ZRAM for in-memory compressed swap, which is what Ubuntu is now doing by default in version 22.04 for the Pi. I was doing it in 14.04 and it worked pretty well: Lubuntu with LXDE and ZRAM was quite snappy for such a low-end machine.
But as druck says: just turning it off completely is not a good move and will have negative side-effects.
A small USB3 SSD will only cost about as much as a 4 or 8GB Pi 4 itself and will substantially improve performance. If you don't want to experiment with USB booting, you can leave your /boot partition on the SD card, and just put the root and swap partitions on the USB3 drive.
Linux is designed to use spare memory as buffers whenever possible, it is released if it is needed for other purposes.
Of course: I thought that was worth pointing out because it can be a surprise to a Linux newbie. Its also where the speed comes from, and is particularly noticeable when writing code in C or Java on a slowish machine with a decent amount of RAM, say an i5-based laptop with 8GB RAM.
The first compilation in a code writing session can be very much faster than subsequent recompiles because the first one needs to load make, the C compiler and linker (or the JVM, ant and the Java compiler) as well as the source code, while subsequent compiler runs will be anything up to 400% faster because the compiler chain binaries and the source files you're working on will still be in RAM from the previous compilation run.
I've timed it for Java: one fairly large project (a duty roster building visual application for a sport club took noticeably longer for the first compilation of the day. I got intriqued, so I measured it to be sure it wasn't a subjective effect by running the compilation under 'time'. It was real: the first compilation of the day took 4 seconds and subsequent compilations took less than a second.
That said, I don't see the same speedup effect on any Pi I use, but I don't have a Pi 4, but I would expect to see it on a Pi 4 that is maxed- out on RAM.
Have something to add? Share your thoughts — no account required.
Ask the community — no account required