git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] copy.c: use `sendfile()` for in-kernel file copying on Linux

From
Jeff King <peff@peff.net>
Date
Feb 15, 2026, 07:43 UTC
Message-ID
<20260215074306.GA86282@coredump.intra.peff.net>
In-Reply-To
<20260213124656.218396-1-integral@archlinux.org>
On Fri, Feb 13, 2026 at 08:46:56PM +0800, George Hu wrote:
> The `sendfile()` system call copies data between one file descriptor
> and another within the kernel, which is more efficient than the
> combination of `read()` and `write()`.

OK, but...does this efficiency matter for the callers of copy_file() and friends? Just skimming over grep results, it mostly seems to be used with files we'd expect to be small. Some possible exceptions I can see:

  - bundle-uri with a file:// uri will use it (so this could be a big
    packfile)
  - in "clone --local" mode without hardlinks available, we might copy a
    packfile

To some degree, if it's easy to use sendfile(), we should just do so if it might be a bit faster. But as responses from others showed, there are some complications we'd have to deal with (portability, fallback, etc). So I think it would be a lot more compelling if we could show a measurable speedup for some real world operation.

-Peff
Previous: George Hu
Message 9 of 9 in “copy.c: use `sendfile()` for in-kernel file copying on Linux”
  1. copy.c: use `sendfile()` for in-kernel file copying on LinuxGeorge Hu, Feb 13, 2026
  2. Chris TorekFeb 13, 2026
  3. George HuFeb 14, 2026
  4. Chris TorekFeb 14, 2026
  5. Ed MasteFeb 20, 2026
  6. Collin FunkFeb 20, 2026
  7. Phillip WoodFeb 14, 2026
  8. George HuFeb 15, 2026
  9. Jeff KingFeb 15, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.