什么是vm.swappiness的百分比?
如果vm.swappiness = 50 < / code>,并且我有一个60克RAM,则使用了20张,而Cache Buffer使用20G,则从技术上讲,我使用的是40 /60 = 66%的RAM。由于这大于交换阈值,这会导致我在我的情况下交换吗?
我希望vm.swappiness
仅依靠不包括缓冲区/缓存的二手内存。不是这样吗?
IF VM.swappiness=50
and I have a 60G RAM, with 20 used by an application and 20G by cache buffer, then technically I am using 40 / 60 = 66% of my RAM. Since this is greater than swappiness threshold, will this cause swapping in my instance?
I expect VM.swappiness
to only rely on USED memory that excludes buffer/cache. Is that not the case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同意,阅读文档。但我会总结..
(不是来自文档)它通常是在线陈述的,就像我在整个情况下看到的那样,vm.swappiness是免费内存的百分比,默认的60将意味着当60%的内存免费时开始交换。事实并非如此。
vm.swappiness(这是从文档中解释的,我已经查看了源代码,文档是准确的)。因此,内核内存管理系统希望释放一些RAM ...它会踢出东西页面缓存(这是磁盘缓存)的内容,或写一些东西以交换。 vm.swappiness确定将某些内容交换的“相对I/O成本”而不是放下一些磁盘缓存(即您认为它会减慢系统的速度。 IS是140(200-60)。 140/60 = 2.33,因此它认为常规磁盘I/O是交换速度的2.33倍。设置vm.swappiness = 100表示交换和磁盘I/O同样快;在现代内核上,如果您有一个快速交换系统(例如一些辅助RAM磁盘或Optane SSD或其他东西),您甚至可以设置Vm.swappiness 100以上的vm.swappiness,说交换比常规磁盘更快。
(不在文档中)对默认值的评论,vm.swappiness = 60。那是我刚开始使用Linux时的默认值,在带有4MB RAM和40MB硬盘的16MHz 386上,在这些较旧的系统上,执行速度足够低,您可以陷入沉重的交换,并且仍然可以得到约10-20%正常速度;与现在相比,您处理相对较小的文件(因此,流过磁盘缓存的“东西”较少)。现在,您拥有带有GB的RAM的系统,100秒的GB到磁盘空间的TBS,更大的文件具有更高的磁盘I/O速率。现在,服务器和桌面设置都很常见,可以推荐1或10的值;而且我认为这现在是合适的,重型磁盘I/O倾向于使系统在现代系统上过度互换,默认60,通过交换GB来维持许多GB的磁盘缓存,而GB的代码确实会使所有人的速度下降,从较低的交换价值。
Agreed, read the docs. But I'll summarize..
(Not from the docs) It's VERY commonly stated online, like I've seen it all over the case, that vm.swappiness is a percentage of free memory, the default 60 would mean to start swapping when 60% of memory is free. This is not the case.
vm.swappiness (this is paraphrased from the docs, and I've looked at the source code and the docs are accurate).. So the kernel memory management system wants to free up some RAM... it'll either kick stuff out of the page cache (this is the disk cache), or write some stuff out to swap. vm.swappiness determines "relative I/O cost" of swapping something out versus dropping some disk cache (i.e. how much you think it'll slow the system down.) Total value is 200, so default vm.swappiness=60 means page cache is 140 (200-60). 140/60=2.33, so it considers regular disk I/o to be about 2.33 times the speed of swap. Settings vm.swappiness=100 means swap and disk I/O are equally fast; on modern kernels, in case you had a fast swap system (like some auxillary RAM disk or optane ssds or something) you can even set vm.swappiness over 100 to say 150 to say swap is faster than your regular disk.
(not in the docs) A comment on the default, vm.swappiness=60. That was the default when I first started using Linux, on a 16mhz 386 with 4MB RAM and a 40MB hard disk, on these older systems the execution speed was low enough you could get into heavy swap and still get like 10-20% of your normal speed; and you dealt with relatively small files compared to now (so less "stuff" flowing through the disk cache). You now have systems with GBs of RAM, 100s of GBs to TBs of disk space, much larger files with much higher disk I/O rates. It's common for both server and desktop setups now to recommend values of 1 or 10; and I think this is now appropriate, heavy disk I/O tends to make the system swap excessively on a modern system with the default 60, maintaining many GBs of disk cache by swapping out GBs of code which really slows things down over all compared to a lower swappiness value.