为什么 L2ARC 没有为目录遍历提供更快的速度?

为什么 L2ARC 没有为目录遍历提供更快的速度?

L2Arc 通常配置为在 SSD 上缓存随机旋转盘片读取。我设置此配置是为了加快目录遍历速度。

设置如下:

# zpool list -v
NAME   SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
geek1  2.72T  1.18T  1.54T         -    53%    43%  4.64x  ONLINE  -
  sdc  1.36T   606G   786G         -    54%    43%
  sdd  1.36T   606G   786G         -    53%    43%
log      -      -      -         -      -      -
  zil  3.97G      0  3.97G         -     0%     0%
cache      -      -      -         -      -      -
  l2arc  32.0G  4.24G  27.8G         -     0%    13%

该机器拥有 20GB 内存:对于 Arc 来说足够了。

我原本以为find文件系统上的调用会大大加快。速度提高了 5 倍,但从绝对意义上讲,它仍然很慢。列出 46M 文件需要 3.4 小时。

# while true; do time find /geek1/ -type f|wc -l; done
46774149

real    1103m18.661s
user    2m15.143s
sys     5m52.096s
46774149

real    243m0.289s
user    2m3.063s
sys     5m7.107s
46774149

real    205m23.922s
user    2m7.566s
sys     6m32.638s

如何使目录遍历更加高效?

zpool get all印刷:

NAME   PROPERTY                    VALUE                       SOURCE
geek1  size                        2.72T                       -
geek1  capacity                    43%                         -
geek1  altroot                     -                           default
geek1  health                      ONLINE                      -
geek1  guid                                                    default
geek1  version                     -                           default
geek1  bootfs                      -                           default
geek1  delegation                  on                          default
geek1  autoreplace                 off                         default
geek1  cachefile                   -                           default
geek1  failmode                    wait                        default
geek1  listsnapshots               off                         default
geek1  autoexpand                  off                         default
geek1  dedupditto                  0                           default
geek1  dedupratio                  4.64x                       -
geek1  free                        1.54T                       -
geek1  allocated                   1.18T                       -
geek1  readonly                    off                         -
geek1  ashift                      0                           default
geek1  comment                     -                           default
geek1  expandsize                  -                           -
geek1  freeing                     0                           default
geek1  fragmentation               53%                         -
geek1  leaked                      0                           default
geek1  feature@async_destroy       enabled                     local
geek1  feature@empty_bpobj         active                      local
geek1  feature@lz4_compress        active                      local
geek1  feature@spacemap_histogram  active                      local
geek1  feature@enabled_txg         active                      local
geek1  feature@hole_birth          active                      local
geek1  feature@extensible_dataset  enabled                     local
geek1  feature@embedded_data       active                      local
geek1  feature@bookmarks           enabled                     local
geek1  feature@filesystem_limits   enabled                     local
geek1  feature@large_blocks        enabled                     local

答案1

如果您在 Linux 上使用 ZFS,则速度缓慢可能取决于xattr默认设置(xattr=on),它将扩展属性存储在隐藏目录/文件中。

尝试将更改设置xattrsa,发出类似 的命令zfs set xattr=sa <pool/fs>。但是,它只会影响新创建的文件;因此您需要删除/重新加载所有文件才能显著加快速度。

换句话说,在重新加载所有文件之前,先进行小规模尝试。

相关内容