[{"data":1,"prerenderedAt":112},["ShallowReactive",2],{"term-z\u002Fzero-copy":3,"related-z\u002Fzero-copy":96},{"id":4,"title":5,"acronym":6,"body":7,"category":77,"description":78,"difficulty":79,"extension":80,"letter":81,"meta":82,"navigation":83,"path":84,"related":85,"seo":90,"sitemap":91,"stem":94,"subcategory":6,"__hash__":95},"terms\u002Fterms\u002Fz\u002Fzero-copy.md","Zero-Copy",null,{"type":8,"value":9,"toc":71},"minimark",[10,15,19,23,26,30,60,64,67],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"Normally, sending a file over the network means the OS copies its bytes from disk into your program's memory, then your program hands it to the OS again to copy into the network buffer, the same data gets duplicated over and over for no real reason. Zero-copy is the trick of skipping those pointless in-between copies entirely, letting the kernel move data straight from the disk cache to the network card without your program's memory ever touching it.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Zero-copy refers to I\u002FO techniques that eliminate unnecessary copying of data between kernel space and user space buffers, typically by using operating system calls like sendfile or splice that let the kernel transfer data directly between a file descriptor and a socket. It significantly reduces CPU usage and memory bandwidth consumption for I\u002FO-heavy workloads like serving static files or proxying data at scale.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-c shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F Linux sendfile: kernel copies file data straight to the socket,\n\u002F\u002F skipping the userspace round trip\nssize_t n = sendfile(socket_fd, file_fd, &offset, count);\n","c","",[38,39,40,48,54],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,47],{},"\u002F\u002F Linux sendfile: kernel copies file data straight to the socket,\n",[41,49,51],{"class":43,"line":50},2,[41,52,53],{},"\u002F\u002F skipping the userspace round trip\n",[41,55,57],{"class":43,"line":56},3,[41,58,59],{},"ssize_t n = sendfile(socket_fd, file_fd, &offset, count);\n",[11,61,63],{"id":62},"when-youll-hear-this","When You'll Hear This",[16,65,66],{},"\"Nginx uses sendfile for zero-copy static file serving.\" \u002F \"We cut CPU usage in half on the proxy by switching to zero-copy transfers.\"",[68,69,70],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":50,"depth":50,"links":72},[73,74,75,76],{"id":13,"depth":50,"text":14},{"id":21,"depth":50,"text":22},{"id":28,"depth":50,"text":29},{"id":62,"depth":50,"text":63},"backend","Normally, sending a file over the network means the OS copies its bytes from disk into your program's memory, then your program hands it to the OS again to...","intermediate","md","z",{},true,"\u002Fterms\u002Fz\u002Fzero-copy",[86,87,88,89],"Syscall","io_uring","Context Switch","Latency",{"title":5,"description":78},{"changefreq":92,"priority":93},"weekly",0.7,"terms\u002Fz\u002Fzero-copy","wH5G01hC1cpxOkVTqx1BKm2M4uTTzca9exgyWnlUhCs",[97,100,104,109],{"title":88,"path":98,"acronym":6,"category":77,"difficulty":79,"description":99},"\u002Fterms\u002Fc\u002Fcontext-switch","A context switch is the CPU pausing whatever thread it's running, carefully saving all its progress like a bookmark, and loading up a completely different...",{"title":87,"path":101,"acronym":6,"category":77,"difficulty":102,"description":103},"\u002Fterms\u002Fi\u002Fio-uring","advanced","io_uring is a modern Linux way of asking the kernel to do I\u002FO work that skips almost all the usual back-and-forth.",{"title":89,"path":105,"acronym":6,"category":106,"difficulty":107,"description":108},"\u002Fterms\u002Fl\u002Flatency","networking","beginner","Latency is the delay before data starts moving — the time it takes for a request to go from your device to the server and back.",{"title":86,"path":110,"acronym":6,"category":77,"difficulty":107,"description":111},"\u002Fterms\u002Fs\u002Fsyscall","A syscall is your program raising its hand and asking the operating system kernel to do something it isn't allowed to do itself, like reading a file, openi...",1792528137246]