<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Io.Copy on Segflow</title><link>https://segflow.github.io/tags/io.copy/</link><description>Recent content in Io.Copy on Segflow</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 22 Jan 2024 10:00:00 +0100</lastBuildDate><atom:link href="https://segflow.github.io/tags/io.copy/index.xml" rel="self" type="application/rss+xml"/><item><title>Zero-copy in Go: sendfile, splice, and the cost of io.Copy</title><link>https://segflow.github.io/post/zero-copy-sendfile-splice/</link><pubDate>Mon, 22 Jan 2024 10:00:00 +0100</pubDate><guid>https://segflow.github.io/post/zero-copy-sendfile-splice/</guid><description>&lt;p&gt;A small file-serving service of mine slowed to a crawl one afternoon after a
&amp;ldquo;harmless&amp;rdquo; middleware change. CPU on the server box doubled, throughput
roughly halved. The diff was a single line: instead of handing a &lt;code&gt;*os.File&lt;/code&gt;
to &lt;code&gt;io.Copy&lt;/code&gt;, somebody had wrapped it in a tiny logging reader to count
bytes.&lt;/p&gt;
&lt;p&gt;That one wrap quietly turned off &lt;code&gt;sendfile(2)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This post is about that fast path: what Go does for you for free, how to see
it actually fire, and the surprisingly easy ways to lose it.&lt;/p&gt;</description></item></channel></rss>