linux 从samba拷贝,提升samba复制速度,树莓派外接硬盘读取从40M到110M(2020-11-15更新)...

在树莓派4上用利用usb3的移动硬盘搭建好samba共享后,发现读取速度只有40M左右,写入速度只有30M左右,这比我预期的速度慢了许多,后面在samba官网文档看到了write cache size选项(新解决方案见后文),开启后读取速度飙升到110M+,基本达到了千兆网络极限,虽然写入速度变化不大,对我来说也是很满意的。

在官方文档上,是这么介绍这个选项的:

If this integer parameter is set to non-zero value, Samba will create an in-memory cache for each oplocked file (it does not do this for non-oplocked files). All writes that the client does not request to be flushed directly to disk will be stored in this cache if possible. The cache is flushed onto disk when a write comes in whose offset would not fit into the cache or when the file is closed by the client. Reads for the file are also served from this cache if the data is stored within it.

This cache allows Samba to batch client writes into a more efficient write size for RAID disks (i.e. writes may be tuned to be the RAID stripe size) and can improve performance on systems where the disk subsystem is a bottleneck but there is free memory for userspace programs.

The integer parameter specifies the size of this cache (per oplocked file) in bytes.

Note that the write cache won’t be used for file handles with a smb2 write lease.

Default: write cache size = 0

Example: write cache size = 262144 # for a 256k cache size per file

大概就是说先在内存中缓存,到了指定大小再一次写入,以此提高samba性能,这个功能默认是关闭的,如果要开启的话需要在[global]节点下开启,比如write cache size = 262144,即设定缓存大小为256k。开启后读取效果提升显著。至于写入速度没有什么提升,我估计是树莓派或外接硬盘物理限制,尝试一些设置后依然如此,故此放弃。

2020-08-04更新

samba4.12.0版本移除了write cache size,详情可看:samba 4.12.0更新日志

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16The smb.conf parameter "write cache size" has been removed.

Since the in-memory write caching code was written, our write path has

changed significantly. In particular we have gained very flexible

support for async I/O, with the new linux io_uring interface in

development. The old write cache concept which cached data in main

memory followed by a blocking pwrite no longer gives any improvement

on modern systems, and may make performance worse on memory-contrained

systems, so this functionality should not be enabled in core smbd

code.

In addition, it complicated the write code, which is a performance

critical code path.

If required for specialist purposes, it can be recreated as a VFS

module.

2020-11-15更新(推荐)

感谢binnan hao同学的提醒和帮助。即在[global]节点下用aio read size = 0替代write cache size = 262144。千兆有线网络下,从树莓派复制5G大文件到电脑,速度稳定在105M/s。这种方式同样支持4.12.0之前的版本,所以大力推荐。

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值