【Netty技术专题】「原理分析系列」Netty强大特性之ByteBuf零拷贝技术原理分析
零拷贝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. This is frequently used to save CPU cycles and memory bandwidth when transmitting a file over a network. 所谓的Zero-copy,就是在操作数据时, 不需要将数据buffer从一个内存区域拷贝到另一个内存区域,少了一次内存的拷贝, 减少了cpu的执行,节省了内存带宽。 操作系统层面Zero-Copy 在OS层面上的Zero-copy通常指避免在用户态(User-space) 与 内核态(Kernel-space) 之间来回拷贝数据。 例如 Linux 提供的 mmap 系统调用, 它可以将一段用户空间内存映射到内核空间, 当映射成功后, 用户对这段内存区域的修改可以直接...




