Questions tagged [zero-copy]

"Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another.

Zero-copy describes computer operations in which the CPU does not perform the task of copying data from one memory area to another. This technique is used in various software elements (e.g.device drivers, file systems, and network protocol stacks) to increase the performance and more efficiently utilize system resources.

Network applications that use zero copy request that the kernel copy the data directly from the disk file to the socket, without going through the application. Zero copy greatly improves application performance and reduces the number of context switches between kernel and user mode.

References:

100 questions
8
votes
2 answers

Is zero-copy UDP packing receiving possibly on Linux?

I would like to have UDP packets copied directly from the ethernet adapter into my userspace buffer Some details on my setup: I am receiving data from a pair of gigabit ethernet cameras. Combined I am receiving 28800 UDP packets per second (1…
Joseph Lisee
  • 3,439
  • 26
  • 21
8
votes
2 answers

Determining whether a readable file descriptor is the read end of a pipe

I would like to use splice to zero-copy data from STDIN_FILENO to a file descriptor (which could be to a regular file, char or block device, FIFO, or anything that can be opened with open). In order to use splice, either the from file descriptor or…
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193
8
votes
2 answers

How to implement zero-copy tcp using lock-free circular buffer in C++

I have multiple threads that need to consume data from a TCP stream. I wish to use a circular buffer/queue in shared memory to read from the TCP socket. The TCP receive will write directly to the circular queue. The consumers will read from the…
jaybny
  • 1,026
  • 2
  • 13
  • 29
7
votes
1 answer

How to get InputStream via Spring-Feign?

I want to download and save a file in local directory from server by Spring-OpenFeign with zero-copy. Naive download method as following: import org.apache.commons.io.FileUtils @GetMapping("/api/v1/files") ResponseEntity
dgregory
  • 1,397
  • 1
  • 12
  • 26
7
votes
3 answers

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

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…
user191513
7
votes
1 answer

Can I use thrust::host_vector or I must use cudaHostAlloc for zero-copy with Thrust?

I want to use zero-copy on mapped memory by cudaHostGetDevicePointer. Can I use thrust::host_vector or I must use cudaHostAlloc(...,cudaHostAllocMapped)? Or is it somehow easier to do with Thrust?
Alex
  • 12,578
  • 15
  • 99
  • 195
6
votes
3 answers

Zero-copy with and without Scatter/Gather operations

I just read an article that explains the zero-copy mechanism. It talks about the difference between zero-copy with and without Scatter/Gather supports. NIC without SG support, the data copies are as follows NIC with SG support, the data copies are…
sliter
  • 1,063
  • 1
  • 17
  • 34
6
votes
1 answer

FileChannel zero-copy transferTo fails to copy bytes to SocketChannel

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…
Sergei Rodionov
  • 4,079
  • 6
  • 27
  • 44
6
votes
5 answers

Can I do a zero-copy std::string allocation in C++ from a const char * array?

Profiling of my application reveals that it is spending nearly 5% of CPU time in string allocation. In many, many places I am making C++ std::string objects from a 64MB char buffer. The thing is, the buffer never changes during the running of the…
vy32
  • 28,461
  • 37
  • 122
  • 246
5
votes
2 answers

How to use OpenCL to write directly to linux framebuffer with zero-copy?

I am using OpenCL to do some image processing and want to use it to write RGBA image directly to framebuffer. Workflow is shown below: 1) map framebuffer to user space. 2) create OpenCL buffer using clCreateBuffer with flags of…
Binn
  • 51
  • 1
5
votes
1 answer

How do I construct string from byte array in D

I have array of bytes which is defined as pointer + size: size_t size; // size in bytes void *data; // NOT zero-terminated string How do I construct, preferably zero-copy, 'string' from it?
Brazhnyk Yuriy
  • 464
  • 4
  • 10
4
votes
2 answers

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

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…
Timothy Miller
  • 1,527
  • 4
  • 28
  • 48
4
votes
2 answers

Linux splice() returning EINVAL ("Invalid argument")

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…
bfallik-bamboom
  • 445
  • 5
  • 12
4
votes
1 answer

Is there a portable way to discard a number of readable bytes from a socket-like file descriptor?

Is there a portable way to discard a number of incoming bytes from a socket without copying them to userspace? On a regular file, I could use lseek(), but on a socket, it's not possible. I have two scenarios where I might need it: A stream of…
Angro
  • 111
  • 1
  • 7
4
votes
1 answer

How do I store a result using Serde Zero-copy deserialization of a Futures-enabled Hyper Chunk?

I'm using futures, tokio, hyper, and serde_json to request and deserialize some data that I need to hold until my next request. My initial thought was to make a struct containing the hyper::Chunk and the deserialized data that borrows from the…
Evin Robertson
  • 288
  • 3
  • 7