Many people do not understand the nature of swap: it's very slow!
For an old machine with DDR3 1600 memory:
- the memory transfer rate is 12800 MB/s,
- a HDD rate is around 100-200 MB/s,
- a SSD rate is maximum 600 MB/s
So if the memory pressure is so high that swap usage is frequent, everything will still work, but will slow down tremendously because the speed of swap is less than 1/1000 of the normal memory.
Where swap can help us in daily life is that if you're running multiple programs, less frequently used program can be swapped out but are still retained in the system. You wait 2-3 minutes to allow less active pages to go to swap, then you can use your current Application without much pain. And in many cases the less active pages never swap back again so there's no further penalty.
But when you talk about simulation, which means your data is huge and swap in/out activities will be frequent, it just looks like your system is freezing, because more than 99.9% of the CPU time is in uninterruptible iowait.
So the solution to your problems is:
- Buy more RAM
- Have tremendous patience and wait 1000 times longer with your current setup
- Add an SSD and still have a lot of patience and wait 100 times longer...
free
command? – Alvin Liang Dec 21 '18 at 02:13man swapon
– waltinator Dec 21 '18 at 02:27free -h
command shows no swap usage, but you may have used that command when nothing was going on. Sure, you could play with various settings likevm.swappiness
, but it wouldn't change the fact that you need more physical RAM. You could also change your script to only read in portions of the text file, so that it doesn't use all of your existing RAM. – heynnema Dec 21 '18 at 03:18