du 磁盘缓存 - 为什么该磁盘在一台机器上比另一台机器上更快?

du 磁盘缓存 - 为什么该磁盘在一台机器上比另一台机器上更快?

如果我将外部硬盘插入 RasberryPi4,然后运行:
time du -sh /mnt/disk/thisfolderis300gb.dir

然后大约需要6分钟,后续所有运行也需要6分钟,

但是,如果我将相同的硬盘插入我老化的 Linux 笔记本电脑,并运行相同的命令,第一次运行也需要 6 分钟,但所有后续运行只需要2秒。

显然某种缓存在这里起作用。这里到底发生了什么,我怎样才能在 RPi 上获得相同的“性能”? (我尝试复制挂载选项,没有效果)

我注意到这两款设备的内存都接近耗尽。

硬件详细信息:
硬盘:外置 2.5 英寸 2TB USB3、ext4。RaspberryPi4
:4GB RAM、USB3。
老化笔记本电脑:6 年以上、16GB RAM、linux mint、仅 USB2。

RaPi 挂载选项:(rw,relatime)
Linux mint 挂载选项:(rw,nosuid,nodev,uhelper=udisks2)

*我尝试使用上述两种安装选项安装在RaPi上,结果是相同的。

笔记本电脑/proc/meminfo,在运行之前

MemTotal:       16386892 kB
MemFree:        11127292 kB
MemAvailable:   13237468 kB
Buffers:          192568 kB
Cached:          2331040 kB
SwapCached:            0 kB
Active:          3166152 kB
Inactive:        1523380 kB
Active(anon):    2166896 kB
Inactive(anon):   312204 kB
Active(file):     999256 kB
Inactive(file):  1211176 kB
Unevictable:          96 kB
Mlocked:              96 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Dirty:               124 kB
Writeback:             0 kB
AnonPages:       2166040 kB
Mapped:           918028 kB
Shmem:            314208 kB
KReclaimable:     238016 kB
Slab:             377336 kB
SReclaimable:     238016 kB
SUnreclaim:       139320 kB
KernelStack:       15360 kB
PageTables:        38840 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    10290592 kB
Committed_AS:   10813140 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       42604 kB
VmallocChunk:          0 kB
Percpu:             6208 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      362240 kB
DirectMap2M:    16404480 kB

笔记本电脑/proc/meminfo,运行du后

MemTotal:       16386892 kB
MemFree:         8264124 kB
MemAvailable:   12752864 kB
Buffers:         1291636 kB
Cached:          2430124 kB
SwapCached:            0 kB
Active:          4706588 kB
Inactive:        1605828 kB
Active(anon):    2591628 kB
Inactive(anon):   346244 kB
Active(file):    2114960 kB
Inactive(file):  1259584 kB
Unevictable:          96 kB
Mlocked:              96 kB
SwapTotal:       2097148 kB
SwapFree:        2097148 kB
Dirty:              5784 kB
Writeback:             0 kB
AnonPages:       2590316 kB
Mapped:           949516 kB
Shmem:            348248 kB
KReclaimable:    1452468 kB
Slab:            1595388 kB
SReclaimable:    1452468 kB
SUnreclaim:       142920 kB
KernelStack:       16544 kB
PageTables:        45964 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    10290592 kB
Committed_AS:   12123736 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       43836 kB
VmallocChunk:          0 kB
Percpu:             6208 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      376576 kB
DirectMap2M:    16390144 kB

RasPi4 /proc/meminfo,在运行 du 之前

MemTotal:        3999784 kB
MemFree:         3828048 kB
MemAvailable:    3789780 kB
Buffers:           14584 kB
Cached:            51556 kB
SwapCached:            0 kB
Active:            48208 kB
Inactive:          32684 kB
Active(anon):      14984 kB
Inactive(anon):     8336 kB
Active(file):      33224 kB
Inactive(file):    24348 kB
Unevictable:          16 kB
Mlocked:              16 kB
HighTotal:       3264512 kB
HighFree:        3189372 kB
LowTotal:         735272 kB
LowFree:          638676 kB
SwapTotal:        524284 kB
SwapFree:         524284 kB
Dirty:                 4 kB
Writeback:             0 kB
AnonPages:         14792 kB
Mapped:            19408 kB
Shmem:              8576 kB
Slab:              34932 kB
SReclaimable:      14160 kB
SUnreclaim:        20772 kB
KernelStack:        1072 kB
PageTables:         1108 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2524176 kB
Committed_AS:      85956 kB
VmallocTotal:     245760 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
Percpu:              608 kB
CmaTotal:         262144 kB
CmaFree:          222908 kB

RasPi4 /proc/meminfo,运行 du 后

MemTotal:        3999784 kB
MemFree:         3274908 kB
MemAvailable:    3742736 kB
Buffers:          428308 kB
Cached:            37832 kB
SwapCached:            0 kB
Active:           254960 kB
Inactive:         227440 kB
Active(anon):      16504 kB
Inactive(anon):     8336 kB
Active(file):     238456 kB
Inactive(file):   219104 kB
Unevictable:          16 kB
Mlocked:              16 kB
HighTotal:       3264512 kB
HighFree:        3200564 kB
LowTotal:         735272 kB
LowFree:           74344 kB
SwapTotal:        524284 kB
SwapFree:         524284 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:         16284 kB
Mapped:            19976 kB
Shmem:              8580 kB
Slab:             185740 kB
SReclaimable:     158128 kB
SUnreclaim:        27612 kB
KernelStack:        1056 kB
PageTables:         1172 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2524176 kB
Committed_AS:      89956 kB
VmallocTotal:     245760 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
Percpu:              608 kB
CmaTotal:         262144 kB
CmaFree:           51616 kB

答案1

答案是,你猜对了,它是缓存。

如何改进缓存:更多 RAM。

  • 停止运行使用大量 RAM 的进程。
  • 获取更多 RAM(Pi 已达到最大容量,因此不是一个选项)。

相关内容