• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

16g ram and I assigned 64g swap, mistake?

azathoth

Well-Known Member

Thanks: 13
Messages: 373

#1
I wonder if so much swap disturbs freebsd auto tuning?

zfs on root
2x500g sas drives in zfs root
 

scottro

Daemon

Thanks: 348
Messages: 1,054

#2
Sounds like too much swap. If you're running ZFS sometimes it's useful to have a (usually inactive) swap partition if using synth, which takes a lot of swap, but even in that case 64GB seems excessive. :)
 

Beastie

Daemon

Thanks: 418
Messages: 2,085

#4
It's a complete waste of disk space. Most probably you won't be using 1/4 of it. Just repartition if it's not too much of a hassle.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,504
Messages: 25,687

#5
Yeah, it's too much. I generally don't assign more than 4-8GB of swap. On low RAM systems (less than 4GB) it's good to keep a ratio of 1,5-2.0 times the amount of RAM. Above 4GB RAM and 8GB of swap that ratio doesn't make sense anymore and it'll just be wasted.

Ideally swap won't get used much any way. Modern operating systems will always use a little bit of swap but this is usually just a tiny amount. If applications start using swap it's typically an indication there's not enough memory in the machine. Some swap usage is acceptable, it's excessive swapping that's problematic.
 

Snurg

Aspiring Daemon

Thanks: 242
Messages: 698

#6
...if using synth, which takes a lot of swap, but even in that case 64GB seems excessive. :)
Will synth use swap if there is sufficient memory? Or, asked the other way, how much RAM should be present to use synth without swapping?
Most probably you won't be using 1/4 of it.
Considering the transfer rate of around 100MB/sec for modern disks, filling 16GB sequentially (ideal case) would take about three minutes.
The reality is not the ideal case. It would slow down the computer that much that one probably will just prefer buying a few more memory modules.
Considering the current street price of around $2 per GB ECC DDR3, I think it makes no real sense to use much swap.
 

ralphbsz

Aspiring Daemon

Thanks: 325
Messages: 762

#10
No. It depends on the workload, or more accurately, on the balance between workload and memory. Example: On your current machine, you have 16G of RAM. Imagine that your workload (I don't care what the workload is, synth is fundamentally no different from others) needs 27G, plus the operating system wants to use some RAM for file system cache. In that case, you will use a little bit over 11G of your swap. Now upgrade your machine to 64G of RAM, and it will need no swap at all (and use a little bit, because the OS will move rarely used stuff into swap and use RAM for file system buffer cache instead).

You need to figure out the balance of swap and RAM for your workload. Parallel compiles are difficult workloads to measure and characterize, because their resource usage fluctuates so much between different phases. They also tend to stress everything (CPU, file IO, memory footprint, memory bandwidth) at different times, and balancing that is hard. For a hobbyist user, the easiest answer is probably to reduce the degree of parallelism: it only makes the compiles slightly slower, and hopefully moves the resource usage out of the problem zone. Everything else will require pain-staking measurements and optimization.
 

Snurg

Aspiring Daemon

Thanks: 242
Messages: 698

#11
(sorry for OT)
Good to know! I now read the full thread scottro linked above. marino mentioned that with sufficient ram one needs practically no swap.
I really must try out Synth soon for that parallel build thing. I guess with 4 builders and 48GB, like marino mentioned, it could reduce the wait time for building very substantially, compared to the normal make.
Does there exist some kind of "Synth guide for dummies" to get an idea how to use it?
 

chrbr

Aspiring Daemon

Thanks: 204
Messages: 594

#12
With too much swap one should get a warning as
Code:
kern.maxswzone exceeded
in /var/log/messages. This happened to my system with 2G RAM and 2x4G swap. I have simple reduced the swap partitions to 3G each because the machine has never run out of swap.
 

Sensucht94

Active Member

Thanks: 144
Messages: 182

#14
hmm if I have zfs on root, how do I shrink swap?
gpart resize -i index [-a alignment] [-s size] [-f flags] geom, see gpart(8)

So, in your case, if you want a 16Gb swap:
Code:
doas swapoff /dev/ada0p*
doas gpart resize -i * -a 4K -s 16G -f C ada0
Where * is the partition number, as shown in gpart show ada0, or given from the output of something like:
swapinfo | grep ada0 | cut -b 11 (if you're on GPT and swap is not a partition of a BSD slice)
 

poorandunlucky

Well-Known Member

Thanks: 25
Messages: 359

#15
I have 16 GB of RAM and I think the only time swap was ever used was that time something was configured to use all of it for itself and the OS had no choice...

It's rarely ever used... You might want to keep 2-4, maybe 5 GB of swap, depending what you're doing, for safety, but

Code:
last pid: 11415;  load averages:  1.99,  2.84,  2.54                                                up 21+00:54:34  18:14:15
134 processes: 1 running, 130 sleeping, 3 zombie
CPU:  1.8% user,  0.0% nice, 11.0% system,  0.1% interrupt, 87.0% idle
Mem: 1210M Active, 4600M Inact, 330M Laundry, 9440M Wired, 271M Free
ARC: 7044M Total, 4735M MFU, 1011M MRU, 6980K Anon, 384M Header, 907M Other
     5300M Compressed, 5941M Uncompressed, 1.12:1 Ratio
Swap: 5120M Total, 275M Used, 4845M Free, 5% Inuse
.

That's even with kern.vm.swap_idle_enabled="1".

FreeBSD just doesn't swap stuff...