V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
jones
V2EX  ›  Linux

有没有熟悉 Linux 内核的人指点一下 vm.dirty_background_ratio 和 vm.dirty_ratio 的疑问?

  •  
  •   jones · 2018-03-14 21:14:38 +08:00 · 3321 次点击
    这是一个创建于 2206 天前的主题,其中的信息可能已经有所发展或是发生改变。
    最近在搞 Linux 内核优化,对写缓冲这方面的内核参数有点儿疑问,请熟悉 Linux 内核的人指点一下:

    1、vm.dirty_background_ratio

    针对这个内核参数,www.kernel.org 给出的官方解释为:
    Contains, as a percentage of total available memory that contains free pages
    and reclaimable pages, the number of pages at which the background kernel
    flusher threads will start writing out dirty data.
    The total available memory is not equal to total system memory.
    其中重点提到了这个比例是空闲内存的占比(未被使用的内存页和可以被回收的内存页),而不是系统内存总量的占比

    但是 RedHat 官方的调优文档中,又给出了另一层意思,如下:
    Defines a percentage value. Writeout of dirty data begins in the background (via pdflush) when dirty data comprises this percentage of total memory. The default value is 10. For database workloads, Red Hat recommends a lower value of 3.
    RedHat 官方的意思是 total memory,这个指什么,系统内存总量还是空闲内存呢?

    2、vm. dirty_ratio

    针对这个内核参数,www.kernel.org 给出的官方解释为:
    Contains, as a percentage of total available memory that contains free pages
    and reclaimable pages, the number of pages at which a process which is
    generating disk writes will itself start writing out dirty data.
    The total available memory is not equal to total system memory.
    其中也强调了这个比例是空闲内存的占比而不是系统内存总量占比

    RedHat 官方调优文档中的说明如下:
    Defines a percentage value. Writeout of dirty data begins (via pdflush) when dirty data comprises this percentage of total system memory. The default value is 20.
    Red Hat recommends a slightly lower value of 15 for database workloads.
    RedHat 官方的意思是 total system memory,这个明显指的就是系统内存总量了吧

    我想确认的是,这两个参数的比例到底是针对系统内存总量还是空闲内存总量呢? Google 半天也没找到一个确切的说法,都是众说纷纭,不知道该相信哪一个,有没有熟悉内核源码的 V 友帮忙从源码角度给定性一下呢,提前感谢了。

    参考文档地址:
    https://www.kernel.org/doc/Documentation/sysctl/vm.txt
    https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/performance_tuning_guide/s-memory-tunables
    2 条回复    2018-03-20 18:03:57 +08:00
    jyf007
        1
    jyf007  
       2018-03-15 09:38:37 +08:00
    抱歉,我不熟,我只知道 bbr
    tomychen
        2
    tomychen  
       2018-03-20 18:03:57 +08:00
    物理内存总量

    其实可以做测试的

    sysctl 指定两个指后用 dd 写入
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3116 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:30 · PVG 22:30 · LAX 07:30 · JFK 10:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.