Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果文件夹下有大量文件,ls性能很差,如何优化? #13

Closed
hryang opened this issue Feb 16, 2016 · 0 comments
Closed

Comments

@hryang
Copy link
Contributor

hryang commented Feb 16, 2016

假设目录d下只有n个文件f,ls d会触发1 opendir + 1 read dir + n getattr fuse调用。 当n很大时,getattr会导致严重的性能问题。

可以从以下两方面优化:

  • 通过-omax_stat_cache_size=xxx参数增大stat cache的size,这样第一次ls会较慢,但是后续的ls就快了,因为文件的元数据都在本地cache中。默认这个值是1000,大约消耗4MB内存,请根据您机器内存大小调整为合适的值。
  • 使用ls -f命令,这个命令会消除n次getattr调用,提高性能。

注:上述数据在centos7.0,fuse2.9.2版本下测得。

@hryang hryang closed this as completed Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant