1 |
On Sat, May 02, 2020 at 10:12:08PM +0800, William Kenworthy wrote: |
2 |
> I am afraid this is an ".. it depends" question. |
3 |
> |
4 |
|
5 |
Yes, I agree. |
6 |
|
7 |
> If you work with large images or data sets, swap can be really handy. |
8 |
> If you are doing a little programming, web browsing, reading email you |
9 |
> will *probably* be ok, but why risk it? |
10 |
> |
11 |
|
12 |
Risk what? Having the OOM killer kill the problematic process? Depending |
13 |
on your usage, this might be the best. Personally I prefer that to a |
14 |
system that is stuck. I never had to force reboot on a system without |
15 |
swap, whereas with swap I had to reboot most of the times swap was used. |
16 |
Also it's super annoying when your system freezes because of a |
17 |
background process swapping (eg. an emerge world update) while your |
18 |
doing something else. |
19 |
|
20 |
I've been running a 8GB system for a year, before that a 4GB system. |
21 |
Both without swap. It's been fine so far. I did have processes killed |
22 |
(eg. firefox compiling), but at least I can continue to use my system |
23 |
without being interrupted by a freeze. It's a lot less frustrating to |
24 |
have to resume a killed compilation than to deal with a frozen system. |
25 |
|
26 |
> I have a 32gb ram in a master server for an mfs filesystem - it normally |
27 |
> sits at about 5GB of ram - however it can go well over 32Gb into swap at |
28 |
> times - the first machine I tried it with only had 4gb ram and crashed |
29 |
> when it filled the ram, and 8g swap taking the test file system with it |
30 |
> - its now production so I am not going to risk it by underprovisioning |
31 |
> swap. My 32Gb desktop is not using any swap at the moment ... but it |
32 |
> has used it at times. |
33 |
> |
34 |
> So, yes its quite likely you wont use swap - but if you do something |
35 |
> that needs it, it can help avoid a very messy crash. |
36 |
> |
37 |
> Swap is slow, but if you actually need it - its probably critical that |
38 |
> you have it! Unless you are really short of disk space, treat it as |
39 |
> insurance :) |
40 |
> |
41 |
> Look into using swapfiles instead of partitions for flexibility, and the |
42 |
> sysctl values of "vm.swappiness" and "vm.vfs_cache_pressure" to manage |
43 |
> swap usage (you can set to not use swap until it really has to - some |
44 |
> have seen the kernel being too eager to swap out causing slowdowns, |
45 |
> though you can make it go in the other direction and "thrash" when it |
46 |
> actually needs to use swap if you go to far. The default kernel swap |
47 |
> mechanism isn't really that bad! |
48 |
> |
49 |
|
50 |
Swapfiles are great, because you can only add them when you need and |
51 |
remove them when you're done. I sometimes use them when emerging large |
52 |
stuff when I have other big processes in memory. |
53 |
|
54 |
> So yes, most of my machines don't need swap *right now* and swap looks |
55 |
> like its not being used so it could be removed, but I cant guarantee |
56 |
> that they never will, and having years of experience using swap I |
57 |
> recommend that its better to be cautious and survive :) |
58 |
|
59 |
My systems usually survive (are not forcibly rebooted) better when there |
60 |
is no swap. But I agree that in the end, it depends on the usage. |