sendfile比send快?
sendfile
看到有文章说sendfile
会比直接的read
和write
快, 就自己尝试跑了程序对比了下时间,实际结果发现效果是有一些的。但是通过网络搜索, 除了了解了sendfile的原理外, 也发现了sendfile
的诸多限制(不同版本会有些许不同), 这些都值得再好好看一下。
Readlist
- Linux零拷贝函数SendFile应用
- linux的sendfile()系统调用
- Linux kernel 的 sendfile 是如何提高性能的
- C, sendfile() and send() difference?
- True zero copy writes to a socket in linux, Be aware, when splicing data from a mmap’ed buffer to a network socket, it is not possible to say when all data has been sent. Even if splice() returns, the network stack may not have sent all data yet. So reusing the buffer may overwrite unsent data.
- Zero-Copy in Linux with sendfile() and splice()
- linux kernel sendfile
Create file for test
-
How can I populate a file with random data?
head -c 1G </dev/urandom >myfile
-
Quickly create a large file on a Linux system
fallocate -l 10G gentoo_root.img
-
Generate File of a certain size?
dd if=/dev/zero of=output.dat bs=1M count=24