Zero-copy
Encyclopedia
"Zero-copy" describes computer operations in which the CPU
Central processing unit
The central processing unit is the portion of a computer system that carries out the instructions of a computer program, to perform the basic arithmetical, logical, and input/output operations of the system. The CPU plays a role somewhat analogous to the brain in the computer. The term has been in...

 does not perform the task of copying data from one memory
Ram
-Animals:*Ram, an uncastrated male sheep*Ram cichlid, a species of freshwater fish endemic to Colombia and Venezuela-Military:*Battering ram*Ramming, a military tactic in which one vehicle runs into another...

 area to another. This is most often used to save on processing power and memory use when sending files over a network.

Principle

Zero-copy versions of operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 elements such as device driver
Device driver
In computing, a device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device....

s, file system
File system
A file system is a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device which contain it. A file system organizes data in an efficient manner and is tuned to the...

s, and network protocol stacks greatly increase the performance of certain application programs and more efficiently utilize system resources. Performance is enhanced by allowing the CPU to move on to other tasks while data copies proceed in parallel in another part of the machine. Also, zero-copy operations reduce the number of time-consuming mode switches between user space and kernel space. System resources are utilized more efficiently since using a sophisticated CPU to perform extensive copy operations, which is a relatively simple task, is wasteful if other simpler system components can do the copying.

As an example, reading a file and then sending it over a network the traditional way requires four data copies and four CPU context switches, if the file is small enough to fit in the file cache. Two of those data copies use the CPU. Sending the same file via zero copy reduces the context switches to two, and eliminates either half, or all CPU data copies.

Zero-copy protocols are especially important for high-speed networks in which the capacity of a network link approaches or exceeds the CPU's processing capacity. In such a case the CPU spends nearly all of its time copying transferred data, and thus becomes a bottleneck which limits the communication rate to below the link's capacity. A rule of thumb used in the industry is that roughly one CPU clock cycle is needed to process one bit of incoming data.

Implementation

Techniques for creating zero-copy software include the use of DMA
Direct memory access
Direct memory access is a feature of modern computers that allows certain hardware subsystems within the computer to access system memory independently of the central processing unit ....

-based copying and memory-mapping through an MMU
Memory management unit
A memory management unit , sometimes called paged memory management unit , is a computer hardware component responsible for handling accesses to memory requested by the CPU...

. These features require specific hardware support and usually involve particular memory alignment requirements.

Programmatic access

Several operating systems support zero-copying of files through specific APIs.

Linux supports zero copy through system calls such as sys/socket.h's sendfile, sendfile64, and splice
Splice (system call)
splice is a Linux-specific system call that moves data between a file descriptor and a pipe without a round trip to user space. The related system call vmsplice moves or copies data between a pipe and user space. Ideally, splice and vmsplice work by remapping pages and do not actually copy any...

.

Windows supports zero copy through the TransmitFile API.

Java input streams can support zero copy through the java.nio.channels.FileChannel's transferTo method if the underlying operating system also supports zero copy.

RDMA (Remote Direct Memory Access) protocols deeply rely on zero-copy techniques.

See also

  • Embedded system
    Embedded system
    An embedded system is a computer system designed for specific control functions within a larger system. often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast, a general-purpose computer, such as a personal...

  • Direct Memory Access
    Direct memory access
    Direct memory access is a feature of modern computers that allows certain hardware subsystems within the computer to access system memory independently of the central processing unit ....

  • Auto-sequencing memory (ASM)
  • Device driver
    Device driver
    In computing, a device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device....

    s
  • Socket Direct Protocol
  • Infiniband
    InfiniBand
    InfiniBand is a switched fabric communications link used in high-performance computing and enterprise data centers. Its features include high throughput, low latency, quality of service and failover, and it is designed to be scalable...

  • programmed IO (PIO)
    Programmed input/output
    Programmed input/output is a method of transferring data between the CPU and a peripheral such as a network adapter or an ATA storage device....


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK