描述
当我尝试在SAMBA共享目录中创build超过100,000个文件时,smbd cpu使用率随着文件数量的增加和性能的降低而增加。 我查看了smbd日志,在创build每个文档之前都会从客户端接收SMB2_FIND请求,请求参数in_file_name =“*”,用来获取整个目录的信息。 也就是说每个文件需要创build一个完整的目录信息,随着子文件数量的增加,性能明显下降。 我想问的是SMB协议是否考虑使用目录下的大量文件,smbd没有办法优化,或者修改configuration可以提高性能?
testing环境
客户端:windows8
服务器:centos7.1
smbd版本:
[root@localhost samba]# ps aux | grep smbd root 3378 0.0 0.3 386040 5800 ? Ss 20:43 0:00 /usr/sbin/smbd root 3380 0.0 0.1 386040 3108 ? S 20:43 0:00 /usr/sbin/smbd root 3385 0.0 0.3 390600 7004 ? S 20:44 0:00 /usr/sbin/smbd root 3504 0.0 0.0 112648 976 pts/0 R+ 21:09 0:00 grep -- color=auto smbd [root@localhost samba]# /usr/sbin/smbd --version Version 4.2.10
testing程序
修改smb.conf
[root@localhost samba]# testparm -s -c Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) Processing section "[1111]" Loaded services file OK. Server role: ROLE_STANDALONE [global] workgroup = MYGROUP server string = Samba Server Version %v security = USER log file = /var/log/samba/log.%m max log size = 900000000 server max protocol = SMB2 idmap config * : backend = tdb [1111] comment = share path = /tmp read only = No
重新启动smbd服务
用TSC(时间戳计数器)计算时间
graphics诊断工具可以安装
最快的方式来逐行读取string的文本文件
基准cp + git on linux vs Windows:为什么这样的区别?
了解一个进程在Linux上等待I / O的时间
[root@localhost samba]# service smb restart Redirecting to /bin/systemctl restart smb.service
将目录映射到networking磁盘
编写testing程序
var writewg sync.WaitGroup var i uint64 for i = 0; i < files; i++ { writewg.Add(1); ctx.sem <- true go func(index uint64) { if isdir { subdir := path + "/dir_" + strconv.FormatUint(index,10) os.MkdirAll(subdir,0777) } else { file := path + "/file_" + strconv.FormatUint(index,10) f,err := os.OpenFile(file,os.O_CREATE|os.O_APPEND|os.O_RDWR,os.ModePerm|os.ModeTemporary) if err != nil { fmt.Println("OpenFile ",file," Failed ",err ); } else { f.Write(ctx.data[0:]) f.Close() } } atomic.AddUint64(&ctx.task.Ops,1) <- ctx.sem writewg.Add(-1) }(i) } writewg.Wait()
运行我的testing程序
创build500个文件
查看日志
[root@localhost samba]# grep "smbd_dirptr_get_entry mask=.*file_0" log.xjl | wc -l 500 [root@localhost samba]# grep "SMB2_OP_FIND" log.xjl | wc -l 1020
Netbeans发布模式C ++速度是Visual Studio 2012的两倍?
为什么设置cpu亲和力会使线程运行速度变慢?
现在是否值得实施一个slab分配器?
当大量磁盘活动发生时,如何使Linux GUI“可用”
是否可以安全地监视生产Linux系统上的Python堆栈?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。