Skip to content

perf: use sendfile(2) for snapshot serving#293

Merged
joshfriend merged 1 commit intomainfrom
jfriend/sendfile-snapshot-serving
May 5, 2026
Merged

perf: use sendfile(2) for snapshot serving#293
joshfriend merged 1 commit intomainfrom
jfriend/sendfile-snapshot-serving

Conversation

@joshfriend
Copy link
Copy Markdown
Contributor

@joshfriend joshfriend commented May 5, 2026

Use http.ServeContent instead of io.Copy when serving cached snapshots from disk. When the disk cache returns an *os.File, ServeContent enables the sendfile(2) syscall for zero-copy transfer and automatically sets Content-Length. This also enables HTTP Range request support for free.

Localhost benchmark on m5d.16xlarge: 348 MB/s → 3,050 MB/s (~8.8x).

@joshfriend joshfriend requested a review from a team as a code owner May 5, 2026 23:27
@joshfriend joshfriend requested review from inez and removed request for a team May 5, 2026 23:27
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a07b3bf674

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/strategy/git/snapshot.go Outdated
@joshfriend joshfriend force-pushed the jfriend/sendfile-snapshot-serving branch from a07b3bf to bff6015 Compare May 5, 2026 23:33
Replace io.Copy with http.ServeContent when serving cached snapshots from
disk. When the cache returns an *os.File, ServeContent uses the sendfile
syscall for zero-copy transfer and automatically sets Content-Length,
enabling HTTP Range request support.

Localhost benchmark: 348 MB/s → 3,050 MB/s (~8.8x improvement).
@joshfriend joshfriend force-pushed the jfriend/sendfile-snapshot-serving branch from bff6015 to c8cb99b Compare May 5, 2026 23:42
@joshfriend joshfriend merged commit 711cc68 into main May 5, 2026
8 checks passed
@joshfriend joshfriend deleted the jfriend/sendfile-snapshot-serving branch May 5, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants