首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

posix_fallocate以4K的间隔一次写入一个字节,导致我的fuse over NFS实现非常慢

posix_fallocate是一个POSIX标准函数,用于在文件中预分配空间。它可以在文件系统中为文件分配指定大小的连续空间,以便后续写入操作更高效。

在给定的问答内容中,提到了使用posix_fallocate以4K的间隔一次写入一个字节,这种方式会导致fuse over NFS实现非常慢。这是因为在NFS网络文件系统中,每次写入都会引起网络传输,而且每次写入的字节数较小,导致了频繁的网络传输和系统调用,从而降低了性能。

为了解决这个问题,可以考虑以下几点:

  1. 调整写入策略:可以修改代码,将写入操作的字节数增加到一个较大的值,例如4K或更大。这样可以减少网络传输和系统调用的次数,提高性能。
  2. 使用缓冲区:可以引入缓冲区,将多个字节的数据先缓存起来,然后一次性写入到文件中。这样可以减少网络传输和系统调用的次数,提高性能。
  3. 考虑使用异步写入:可以将写入操作改为异步方式,即将数据写入到缓冲区后立即返回,由后台线程负责将数据写入到文件中。这样可以减少写入操作对主线程的阻塞,提高性能。
  4. 考虑使用其他文件分配方式:如果posix_fallocate在fuse over NFS实现中性能较差,可以尝试使用其他文件分配方式,例如使用ftruncate函数来分配文件空间。

总结起来,为了提高fuse over NFS实现的性能,可以通过调整写入策略、使用缓冲区、异步写入等方式来优化。另外,还可以考虑使用其他文件分配方式来替代posix_fallocate。具体的优化方案需要根据具体情况进行调整和实验。

腾讯云相关产品和产品介绍链接地址:

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

fio基础9

randrepeat=boolForrandomIOworkloads,seedthegeneratorinapredictablewaysothatresultsarerepeatableacrossrepetitions.Defaultstotrue.randseed=intSeedtherandomnumbergeneratorsbasedonthisseedvalue,tobeabletocontrolwhatsequenceofoutputisbeinggenerated.Ifnotset,therandomsequencedependsontherandrepeatsetting.fallocate=strWhetherpre-allocationisperformedwhenlayingdownfiles.Acceptedvaluesare:noneDonotpre-allocatespaceposixPre-allocateviaposix_fallocate()keepPre-allocateviafallocate()withFALLOC_FL_KEEP_SIZEset0Backward-compatiblealiasfor'none'1Backward-compatiblealiasfor'posix'Maynotbeavailableonallsupportedplatforms.'keep'isonlyavailableonLinux.IfusingZFSonSolaristhismustbesetto'none'becauseZFSdoesn't support it. Default: 'posix'. fadvise_hint=bool By default, fio will use fadvise() to advise the kernel on what IO patterns it is likely to issue. Sometimes you want to test specific IO patterns without telling the kernel about it, in which case you can disable this option. If set, fio will use POSIX_FADV_SEQUENTIAL for sequential IO and POSIX_FADV_RANDOM for random IO. fadvise_stream=int Notify the kernel what write stream ID to place these writes under. Only supported on Linux. Note, this option may change going forward. size=int The total size of file io for this job. Fio will run until this many bytes has been transferred, unless runtime is limited by other options (such as 'runtime', for instance, or increased/decreased by 'io_size'). Unless specific nrfiles and filesize options are given, fio will divide this size between the available files specified by the job. If not set, fio will use the full size of the given files or devices. If the files do not exist, size must be given. It is also possible to give size as a percentage between 1 and 100. If size=20% is given, fio will use 20% of the full size of the given files or devices. io_size=int io_limit=int Normally fio operates within the region set by 'size', which means that the 'size' option sets both the region and size of IO to

05

[linux][fuse]fuse技术分析以及遇到的问题

前言: 简单看了一下glusterfs,使用单节点构造glusterfs环境,导出的路径是是本地SSD在分区上。用qemu挂载glusterfs上的卷,用FIO测试IOPS,测试结果不理想。 大致分析了一下,怀疑fuse会导致性能下降。 分析: 1,libfuse & fuse 为了方便测试和便于分析问题,使用了libfuse。代码地址https://github.com/libfuse/libfuse 编译libfuse比较麻烦,不支持Makefile,需要用meson编译,而且meson的版本要求比较高,不能用apt-get直接安装。操作方法就是下载高版本的meson包,在meson包里面执行python3 setup.py install。 除了用户态的libfuse之外,还需要kernel支持。作者在Ubuntu1804上测试,fuse已经被编译到kernel中。在config文件(内核配置文件即ls /boot/config-`uname -r`)中CONFIG_FUSE_FS。如果是kmod的方式编译,执行modprobe fuse。

03

IOR中文文档

IOR是一个并行的IO基准,可用于测试使用各种接口和访问模式的并行存储系统的性能。接口和访问模式的并行存储系统的性能。IOR资源库还包括mdtest基准,专门测试不同目录结构下存储系统的元数据峰值速率。在不同目录结构下存储系统的元数据峰值速率。这两个基准都使用一个共同的并行 I/O抽象后端,并依靠MPI进行同步。本文档由两部分组成。用户文档包括安装说明(Install),初学者教程(IOR的第一步),以及关于IOR的运行时选项的信息。开发者文档包括用Doxygen生成的代码文档和一些关于与Travis的连续整合的说明。IOR/mdtest用户和开发者文档的许多方面都是不完整的,我们鼓励贡献者 鼓励贡献者直接评论代码或在此基础上扩展文档。

01
领券