<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rushikesh Deshpande on Medium]]></title>
        <description><![CDATA[Stories by Rushikesh Deshpande on Medium]]></description>
        <link>https://medium.com/@rushikeshdeshpande?source=rss-8f6612e4e27a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LBGOnQXPtrWZyOEs.</url>
            <title>Stories by Rushikesh Deshpande on Medium</title>
            <link>https://medium.com/@rushikeshdeshpande?source=rss-8f6612e4e27a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:22:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rushikeshdeshpande/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Zero-Copy Linux Syscalls: Why sendfile() Is Not Always Faster]]></title>
            <link>https://medium.com/@rushikeshdeshpande/zero-copy-linux-syscalls-why-sendfile-is-not-always-faster-ab8dfd435f7d?source=rss-8f6612e4e27a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab8dfd435f7d</guid>
            <category><![CDATA[linux-kernel]]></category>
            <category><![CDATA[seaweedfs]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Rushikesh Deshpande]]></dc:creator>
            <pubDate>Thu, 07 May 2026 02:34:56 GMT</pubDate>
            <atom:updated>2026-05-07T02:35:21.816Z</atom:updated>
            <content:encoded><![CDATA[<p>For years, Linux zero-copy syscalls like sendfile(), splice(), and copy_file_range() have been presented as obvious performance optimizations.</p><p>The common narrative is simple:</p><blockquote><em>Avoid userspace copies = less CPU = higher throughput = better performance.</em></blockquote><p>But after building production-like compaction benchmarks inspired by SeaweedFS volume compaction, I found something more interesting:</p><blockquote><em>Zero-copy syscalls often optimize CPU efficiency more than raw throughput.</em></blockquote><p>And in some workloads, traditional read()/write() can actually outperform sendfile().</p><p>This article explains why.</p><h3>Traditional Copy Path</h3><p>Most applications copy data using:</p><pre>read(fd_in, buf, size);<br>write(fd_out, buf, size);</pre><p>The data flow looks like this:</p><pre>Disk<br>  -&gt; Kernel Page Cache<br>      -&gt; Userspace Buffer<br>          -&gt; Kernel Buffer<br>              -&gt; Destination</pre><p>This introduces:</p><ul><li>Extra memory copies</li><li>Userspace buffering</li><li>Cache pollution</li><li>Syscall overhead</li><li>GC pressure in managed runtimes like Go</li></ul><h3>What sendfile() Changes</h3><p>sendfile() removes the userspace bounce buffer:</p><pre>Disk<br>  -&gt; Kernel Page Cache<br>      -&gt; Kernel Buffer<br>          -&gt; Destination</pre><p>The syscall itself is simple:</p><pre>sendfile(out_fd, in_fd, &amp;offset, size);</pre><p>The important detail is this:</p><blockquote><em>“Zero-copy” usually means zero copies between kernel and userspace.</em></blockquote><p>It does NOT necessarily mean:</p><pre>No memory copies anywhere</pre><p>The kernel may still:</p><ul><li>Allocate pages</li><li>Copy cache lines</li><li>Manipulate socket buffers</li><li>Track dirty pages</li><li>Perform DMA setup</li></ul><p>This distinction is critical.</p><h3>Where sendfile() Actually Shines</h3><p>The strongest workload for sendfile() is:</p><pre>file -&gt; socket</pre><p>Examples include:</p><ul><li>HTTP static file serving</li><li>CDN edge servers</li><li>Video streaming</li><li>Object storage downloads</li><li>Backup streaming</li></ul><p>This is why systems like NGINX, Cloudflare, and Netflix Open Connect heavily rely on kernel-assisted zero-copy paths.</p><p>In these workloads, Linux can often attach page-cache pages directly to socket buffers, avoiding expensive userspace round-trips.</p><h3>Building a Production-Like Benchmark</h3><p>I wanted to evaluate whether zero-copy techniques could improve storage-system compaction workloads similar to SeaweedFS.</p><p>Instead of building a synthetic sequential-copy benchmark, I created a benchmark that simulates:</p><pre>volume compaction</pre><p>The benchmark:</p><ul><li>Creates a large “volume file”</li><li>Generates sparse “live regions”</li><li>Rewrites only live regions</li><li>Compares:</li><li>Traditional Go buffered copy</li><li>Linux sendfile()</li></ul><p>The workload resembles real compaction behavior:</p><pre>seek -&gt; copy live region -&gt; seek -&gt; rewrite</pre><p>rather than simple sequential streaming.</p><h3>Benchmark Results</h3><p>Example run:</p><pre>=== USERSpace read/write compaction ===</pre><pre>Data copied      : 664 MB<br>Wall time        : 8.60 sec<br>CPU time         : 0.63 sec<br>Throughput       : 77.17 MB/s<br>CPU per GB       : 0.97 sec</pre><pre>=== SENDFILE compaction ===</pre><pre>Data copied      : 664 MB<br>Wall time        : 9.06 sec<br>CPU time         : 0.59 sec<br>Throughput       : 73.28 MB/s<br>CPU per GB       : 0.91 sec</pre><p>At first glance:</p><pre>sendfile() appears slower</pre><p>But that conclusion would be incomplete.</p><h3>The Important Observation</h3><p>The key metric is not throughput.</p><p>It is:</p><pre>CPU cost per GB transferred</pre><p>The benchmark showed:</p><p>MethodCPU per GBread/write0.97 secsendfile0.91 sec</p><p>That means:</p><blockquote><em>sendfile() used less CPU to move the same amount of data.</em></blockquote><p>This distinction matters enormously at scale.</p><h3>Why Throughput Was Worse</h3><p>The workload explains the result.</p><p>This was NOT a streaming workload.</p><p>It was:</p><pre>fragmented sparse-region compaction</pre><p>That introduces:</p><ul><li>Random seeks</li><li>Fragmented writes</li><li>Page-cache churn</li><li>Dirty-page tracking</li><li>Metadata overhead</li><li>Writeback scheduling</li></ul><p>In this workload:</p><pre>modern memcpy becomes surprisingly competitive</pre><p>especially because:</p><ul><li>CPUs have AVX2/AVX-512 optimized memcpy</li><li>Linux aggressively optimizes page-cache copies</li><li>The benchmark was largely page-cache resident</li></ul><h3>The Benchmark Revealed Another Important Effect</h3><p>Heap and GC pressure changed noticeably.</p><p>Buffered userspace copying caused:</p><pre>additional Go heap activity</pre><p>while the sendfile() path showed:</p><pre>near-zero heap growth</pre><p>This matters because storage systems often suffer from:</p><ul><li>GC pauses</li><li>Allocator contention</li><li>Tail latency spikes</li><li>Concurrent compaction interference</li></ul><p>Reducing heap churn can be more valuable than improving raw MB/s.</p><h3>Why File→File Is Different</h3><p>One major realization from this benchmark:</p><blockquote><em>sendfile() was historically optimized for file→socket, not file→file.</em></blockquote><p>In file→file copies, Linux often still needs to:</p><ul><li>Allocate destination pages</li><li>Dirty filesystem pages</li><li>Manage writeback state</li></ul><p>So the kernel cannot always avoid internal memory movement.</p><p>This is why modern Linux introduced specialized syscalls:</p><p>SyscallPurposesendfile()file → socketsplice()pipe-based movementcopy_file_range()file → fileio_uringasync high-performance IO</p><p>For modern storage systems:</p><pre>copy_file_range()</pre><p>may actually be a more relevant primitive than sendfile().</p><h3>The Biggest Lesson</h3><p>This experiment reinforced an important systems-engineering principle:</p><pre>Microbenchmarks can mislead badly.</pre><p>Performance depends heavily on:</p><ul><li>Workload shape</li><li>Page-cache state</li><li>Filesystem behavior</li><li>Syscall patterns</li><li>CPU architecture</li><li>Memory bandwidth</li><li>Socket involvement</li><li>Concurrency level</li></ul><p>There is no universally “fastest” syscall.</p><h3>Why Zero-Copy Still Matters</h3><p>Despite throughput being slightly lower, the benchmark strongly suggests that zero-copy techniques still have real value for storage systems.</p><p>The likely benefits are:</p><ul><li>Lower CPU usage</li><li>Reduced userspace allocations</li><li>Lower GC pressure</li><li>Better compaction concurrency</li><li>Improved tail latency</li><li>Better CPU scalability at high throughput</li></ul><p>In real distributed storage clusters, those characteristics often matter more than single-thread benchmark throughput.</p><h3>The Likely Winning Architecture</h3><p>The most practical design is usually not:</p><pre>full kernel-only data movement</pre><p>Instead, mature systems evolve toward:</p><pre>userspace control plane<br>+<br>kernel-assisted data plane</pre><p>For example:</p><pre>Go:<br>  metadata parsing<br>  indexing<br>  compaction planning</pre><pre>Kernel:<br>  bulk blob movement</pre><p>This hybrid architecture is common in:</p><ul><li>Storage systems</li><li>Object stores</li><li>CDN infrastructure</li><li>Database engines</li><li>Backup appliances</li></ul><h3>Final Thoughts</h3><p>Zero-copy Linux syscalls are powerful tools, but they are not magic performance buttons.</p><p>The real engineering question is not:</p><pre>&quot;Is sendfile faster?&quot;</pre><p>The real question is:</p><pre>&quot;What resource are we optimizing?&quot;</pre><p>Sometimes that is throughput.</p><p>But in modern distributed systems, it is often:</p><ul><li>CPU efficiency</li><li>Memory pressure</li><li>Cache behavior</li><li>GC reduction</li><li>Concurrency scalability</li></ul><p>And that is where zero-copy techniques become truly interesting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab8dfd435f7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NVME Drivers]]></title>
            <link>https://medium.com/@rushikeshdeshpande/nvme-drivers-9fcb069961b9?source=rss-8f6612e4e27a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fcb069961b9</guid>
            <category><![CDATA[nvme]]></category>
            <dc:creator><![CDATA[Rushikesh Deshpande]]></dc:creator>
            <pubDate>Mon, 26 Aug 2019 05:34:00 GMT</pubDate>
            <atom:updated>2019-08-26T05:34:00.207Z</atom:updated>
            <content:encoded><![CDATA[<p>Currently nvme ssd are not standard. But they are trending and lot of PCs and storage arrays are adopting nvme ssd in place of standard ssd.</p><p>The standard SSD didnt require specific drivers. But NVME require specific drivers for optimal performance.</p><p>Almost all major OSes have specific NVME drivers.</p><p>1. Windows</p><p>2. Linux</p><p>3. FreeBSD</p><p>4. VMWare</p><p>5. Solaris</p><p>6. UEFI Bios Drivers</p><p>1. Windows Driver — Microsoft Inbox</p><p>The driver is provided with latest Windows 10 and Windows server 2016</p><p>Following are features of this driver.</p><p>· Closed source driver (Microsoft)</p><p>· Inbox driver to Windows operating systems (not available as standalone driver)</p><p>· NVMe 1.2e compliant (no support for multi-initiator, NS mgmt, controller list, etc.)</p><p>· It is also power efficient with built in modern standby feature</p><p>· Allows vendor specific functionality within inbox driver via pass through support</p><p>The following link explains some features:</p><p><a href="https://docs.microsoft.com/en-us/windows/win32/fileio/working-with-nvme-devices">https://docs.microsoft.com/en-us/windows/win32/fileio/working-with-nvme-devices</a></p><p>2. Linux Driver</p><p>All major Linux distributions have NVMe driver in-box support. The driver supports the mandatory features of the NVMe 1.0c specification.</p><p>Current functionality implemented for NVMe Host Driver</p><p>· Support for RDMA transport ( Infiniband/ RoCE /iWARP )</p><p>· Connect/Disconnect to multiple controllers</p><p>· Transport of NVMe commands/data generated by NVMe core</p><p>· Initial Discovery service implementation</p><p>· Multi-Path</p><p>· Keep Alive</p><p>Current functionality implemented for NVMe Target Driver</p><p>• Support for mandatory NVMe core and Fabrics commands</p><p>• Support for multiple hosts/subsystems/controls/namespaces</p><p>• Namespaces backed by Linux block devices</p><p>• Initial Discovery service; Discovery Subsystem/Controller(s)</p><p>• Target Configuration interface using Linux configfs</p><p>• Create NVM and Discovery Subsystems</p><p>Drivers are currently available at <a href="https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers?h=v5.2.9">https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers?h=v5.2.9</a></p><p>3. SPDK (Storage Performance Developer Kit)</p><p>The Storage Performance Development Kit (SPDK) provides a set of tools and libraries for writing high performance, scalable, user-mode storage applications. It achieves high performance through the use of a number of key techniques:</p><p>· Moving all of the necessary drivers into userspace, which avoids syscalls and enables zero-copy access from the application.</p><p>· Polling hardware for completions instead of relying on interrupts, which lowers both total latency and latency variance.</p><p>· Avoiding all locks in the I/O path, instead relying on message passing.</p><p>The bedrock of SPDK is a user space, polled-mode, asynchronous, lockless NVMe driver.</p><p>4. FreeBSD NVME Driver</p><p>The nvme driver includes following :</p><p>1. nvme module</p><p>- full mandatory NVM command set support</p><p>- per-CPU IO queues (enabled by default but configurable)</p><p>- per-queue sysctls for statistics and full command/completion queue</p><p>dumps for debugging</p><p>- registration API for NVMe namespace consumers</p><p>- I/O error handling (except for timeoutsee below)</p><p>- compilation switches for support back to stable-7</p><p>nvd module</p><p>- BIO_DELETE and BIO_FLUSH (if supported by controller)</p><p>- proper BIO_ORDERED handling</p><p>nvmecontrol utility</p><p>- devlist: list NVMe controllers and their namespaces</p><p>- identify: display controller or namespace identify data in</p><p>human-readable or hex format</p><p>- perftest: quick and dirty performance test to measure raw</p><p>performance of NVMe device without userspace/physio/GEOM</p><p>overhead</p><p>nda module</p><p>- basically it is nvme cam disk driver</p><p>5. VMWare NVME Driver</p><p>The driver includes 4 components suppporting NVM Express for VMware:</p><p>1. VMware native NVM Express driver compatible with NVM Express Specification 1.2</p><p>2. Sample userworld management tool: nvme-cli</p><p>3. Plugin of esxcli for managment: esxcli-nvme-plugin</p><p>4. Unit Test framework for NVMe driver: nvme-test</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fcb069961b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>