zero-copy

How to use Zero-copy sendmsg/Receive in Boost.Asio [closed]

六月ゝ 毕业季﹏ 提交于 2021-01-28 11:21:46
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago . Improve this question I am using Boost.Asio, I want to improve my system by using Zero-copy sendmsg/Receive. Can I use Zero-copy sendmsg/Receive in Boost.Asio? Could you give me how to use them if I can use them? 回答1: Short answer, you can only if your in-memory representation

Does Python support zero-copy I/O?

被刻印的时光 ゝ 提交于 2021-01-21 03:45:41
问题 I have two open file objects, dest and src . File object dest is opened for writing, with the seek position placed at some offset within the file, and file object src is opened for reading. What I need to do is simply read from the current position in src to EOF and transfer the contents to dest as quickly as possible. If I were programming in Java, I could utilize the FileChannel#transferTo() method to perform zero-copy file I/O. Does Python also support zero-copy? 回答1: Since version 3.3,

FileChannel zero-copy transferTo fails to copy bytes to SocketChannel

大兔子大兔子 提交于 2020-01-02 04:55:08
问题 I'm seeing some strange behavior when transferring large files from file to socket using zero-copy in Java. My environments: Windows 7 64-bit JDK 1.6.0_45 and 1.7.0_79. Centos 6.6 64-bit JDK 1.6.0_35 What the program does: client copies an input file into a socket, and server copies socket to output file using zero-copy methods: transferFrom and transferTo. Not all bytes are reaching the server if file size is relatively large, 100Mb+ in case of Windows and 2GB+ in case of Centos. Client and

vmsplice() and TCP

安稳与你 提交于 2019-12-20 11:31:16
问题 In the original vmsplice() implementation, it was suggested that if you had a user-land buffer 2x the maximum number of pages that could fit in a pipe, a successful vmsplice() on the second half of the buffer would guarantee that the kernel was done using the first half of the buffer. But that was not true after all, and particularly for TCP, the kernel pages would be kept until receiving ACK from the other side. Fixing this was left as future work, and thus for TCP, the kernel would still

Send data to multiple sockets using pipes, tee() and splice()

狂风中的少年 提交于 2019-12-20 09:40:00
问题 I'm duplicating a "master" pipe with tee() to write to multiple sockets using splice(). Naturally these pipes will get emptied at different rates depending on how much I can splice() to the destination sockets. So when I next go to add data to the "master" pipe and then tee() it again, I may have a situation where I can write 64KB to the pipe but only tee 4KB to one of the "slave" pipes. I'm guessing then that if I splice() all of the "master" pipe to the socket, I will never be able to tee()

Zero-copy construction of an Eigen SparseMatrix

回眸只為那壹抹淺笑 提交于 2019-12-10 19:05:31
问题 I have the following problem: I have an Eigen::SparseMatrix I need to send over the network, and my network library only supports sending arrays of primitive types. I can retrieve the pointers to the backing arrays of my SparseMatrix by doing something like (here's the backing object's code): // Get pointers to the indices and values, send data over the network int num_items = sparse_matrix.nonZeros() auto values_ptr = sparse_matrix.data().valuePtr() auto index_ptr = sparse_matrix.data()

How can I use Linux's splice() function to copy a file to another file?

a 夏天 提交于 2019-12-10 03:47:06
问题 here's another question about splice(). I'm hoping to use it to copy files, and am trying to use two splice calls joined by a pipe like the example on splice's Wikipedia page. I wrote a simple test case which only tries to read the first 32K bytes from one file and write them to another: #define _GNU_SOURCE #include <fcntl.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #include <string.h> int main(int argc, char **argv) { int pipefd[2]; int result; FILE *in_file; FILE *out_file;

Does Zero-copy exist in Windows OS?

若如初见. 提交于 2019-12-08 15:59:05
问题 Reading this zero copy article, Does Zero-copy exist in Windows OS (server 2003, 2008, 2008 R2) ? 回答1: Yes, it is supported via the TransmitFile API. I'm pretty sure that IIS uses this as well. Whether or not this method does real zero-copy (i.e. doesn't even copy from the file buffers to the socket buffers) is not explicitly mentioned in the documentation. But given the fact that this method is defined in a way that definitely makes it possible, I'd be highly surprised if this were not the

Linux splice() returning EINVAL (“Invalid argument”)

江枫思渺然 提交于 2019-12-07 10:54:48
问题 I'm trying to experiment with using splice (man 2 splice) to copy data from a UDP socket directly to a file. Unfortunately the first call to splice() returns EINVAL. The man page states: EINVAL Target file system doesn't support splicing; target file is opened in append mode; neither of the descriptors refers to a pipe; or offset given for nonseekable device. However, I believe none of those conditions apply. I'm using Fedora 15 (kernel 2.6.40-4) so I believe splice() is supported on all

Linux sockets: Zero-copy local, TCP/IP remote

百般思念 提交于 2019-12-06 06:09:58
问题 Networking is my worst area in operating systems, so forgive me for asking perhaps an incomplete question. I've been reading about this for a few hours, but it's kinda swimming in my head. (To me, I feel like chip design is easy compared to figuring out networking protocols.) I have some networked services that communicate with each other via sockets. Specifically, the sockets are created with fd = socket(PF_INET, SOCK_STREAM, 0); , which automatically gets TCP/IP. I need this as the base