网络 SONiC:SONiC 中的系统内存使用情况 —“buff/available”

Summary: 本文介绍了 Dell Networking SONiC 本机 CLI 中“top”输出中的“buff/cache”和“avail Mem”字段的含义。

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Instructions

  • 问题 1:什么是buff/cache?

    “buff/cache”是指用于文件系统缓冲区和高速缓存的内存量。这种内存使用是 Linux 管理和优化系统性能的关键部分。让我们分解一下“buff/cache”的含义:

    缓冲区:
    此上下文中的缓冲区表示系统内存 (RAM) 的一部分,用于临时保存正在从磁盘读取或写入磁盘的数据。例如,当程序从文件中读取数据时,数据首先加载到内存中的缓冲区中。缓冲区有助于提高磁盘 I/O 性能,因为读取或写入 RAM 的速度比访问物理磁盘快。缓冲区还可以确保更高效地将数据写入磁盘,从而减少磁盘 I/O作的数量。

    高速缓存:
    在此上下文中,高速缓存表示用于存储文件和目录中频繁访问的数据的内存部分。Linux 使用一种称为“页面高速缓存”的机制来缓存最近读取或写入的文件和目录中的数据。这些缓存的数据保存在内存中,因此,如果再次需要相同的数据,可以从 RAM 中快速检索这些数据,而不是从速度较慢的磁盘存储中读取数据。此高速缓存可减少频繁使用数据访问磁盘的要求,从而显著提高系统性能。

    当应用程序或作系统需要更多内存用于活动进程时,可以快速释放缓冲区/高速缓存内存以满足这些需求。

    “top”命令显示此值。它还显示系统的当前状态、CPU 使用情况、内存使用情况。

    提醒:“top”命令仅在 SONiC 的本机 CLI 中起作用,而在戴尔的 MF-CLI(MF-CLI 是戴尔的自定义“管理框架”cli)中不起作用。本机 CLI 是首次启动 SONiC 交换机时显示的命令行界面。在初始本机 CLI 中键入“sonic-cli”后,即到达 MF-CLI。
    admin@sonic:~$ top
    top - 16:43:51 up 8 days, 18:15,  1 user,  load average: 1.54, 1.50, 1.51
    Tasks: 365 total,   2 running, 363 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  2.8 us,  4.2 sy,  0.0 ni, 93.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    MiB Mem :  15482.2 total,  11292.8 free,   2299.6 used,   1889.8 buff/cache 
    MiB Swap:      0.0 total,      0.0 free,      0.0 used.  12965.1 avail Mem
  • 问题 2:缓冲区/高速缓存利用率高的阈值是什么?

    缓冲区/高速缓存用作高速缓存,以存储频繁访问的数据。因此,最终可能会为此目的分配很大一部分可用 RAM。需要注意的是,缓冲区/高速缓存内存的使用是高度动态的,并且会根据系统需求不断变化。因此,监视整体内存使用情况(或相应的“可用内存”)并确保系统具有足够的可用内存来运行应用程序和进程更有价值。

    top - 14:17:13 up 207 days,  1:59,  1 user,  load average: 2.66, 2.19, 2.03
    Tasks: 386 total,   2 running, 384 sleeping,   0 stopped,   0 zombie
    %Cpu(s): 12.5 us,  9.7 sy,  0.0 ni, 77.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    MiB Mem :  15482.6 total,   8571.4 free,   2692.5 used,   4218.8 buff/cache
    MiB Swap:      0.0 total,      0.0 free,      0.0 used.  12773.1 avail Mem   <--- system's total available RAM

    用于表示可在 Dell Enterprise SONiC 交换机上使用的系统 RAM 百分比的有用命令:

    free | grep Mem | awk '{print $7/$2 * 100 }'

    此命令将“avail Mem”除以“MiB Mem total”。

    下面是另一个示例,比较上述命令并指示它们之间的关系,供您参考:

    admin@Leaf3B:~$ top
    top - 21:49:49 up  1:25,  1 user,  load average: 0.59, 0.60, 0.64
    Tasks: 329 total,   1 running, 328 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  7.9 us,  4.2 sy,  0.0 ni, 87.5 id,  0.0 wa,  0.0 hi,  0.4 si,  0.0 st
    KiB Mem : 15928852 total, 12074024 free,  2439884 used,  1414944 buff/cache
    KiB Swap:        0 total,        0 free,        0 used. 13120520 avail Mem
    
      PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
    21685 root      20   0  172992  33116   8436 S  52.9  0.2   3:16.11 python3.6
     1278 root      20   0   92872  15116   3264 S  17.6  0.1   2:24.49 redis-serv+
     5366 admin     20   0   43540   3812   3020 R  17.6  0.0   0:00.03 top
    18469 root      20   0 1643080 451968  78276 S  11.8  2.8   8:17.32 syncd
     1097 root      20   0  136440  15188   5912 S   5.9  0.1   0:07.75 watchdogd
    19856 admin     20   0  334880  61900  35296 S   5.9  0.4   0:00.44 docker
    20985 root      20   0  159488  18616   5036 S   5.9  0.1   0:19.22 xcvrd
        1 root      20   0   57768   7820   5544 S   0.0  0.0   0:32.58 systemd
        2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd
        3 root      20   0       0      0      0 S   0.0  0.0   0:00.91 ksoftirqd/0
        4 root      20   0       0      0      0 S   0.0  0.0   0:01.90 kworker/0:0
        5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:+
        7 root      20   0       0      0      0 S   0.0  0.0   0:06.93 rcu_sched
        8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh
        9 root      rt   0       0      0      0 S   0.0  0.0   0:00.39 migration/0
       10 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 lru-add-dr+
       11 root      rt   0       0      0      0 S   0.0  0.0   0:00.00 watchdog/0
    
    admin@Leaf3B:~$ free
                  total        used        free      shared  buff/cache   available
    Mem:       15928852     2438836    12074940       36060     1415076    13121528
    Swap:             0           0           0
    admin@Leaf3B:~$ free | grep Mem | awk '{print $7/$2 * 100 }'
    82.3662
    admin@Leaf3B:~$

 

Affected Products

Enterprise SONiC Distribution
Article Properties
Article Number: 000215960
Article Type: How To
Last Modified: 17 شباط 2025
Version:  3
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.