[PR #360] [MERGED] Fix request copies #41366

Closed
opened 2026-04-24 21:15:39 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/360
Author: @mxyng
Created: 8/16/2023
Status: Merged
Merged: 8/17/2023
Merged by: @mxyng

Base: mainHead: fix-request-copies


📝 Commits (2)

  • 56e87ce images: remove body copies
  • 9f944c0 push: retry on unauthorized

📊 Changes

1 file changed (+25 additions, -37 deletions)

View changed files

📝 server/images.go (+25 -37)

📄 Description

makeRequest makes copies of the request body via bytes.Buffer and bytes.Reader in anticipation of a possible retry. While the memory requirements are negligible for most requests, the copies become significant when pushing a model blob. A sufficiently large model will exhaust all memory on the system causing the process to be kill by the host OS.

This copy also produces inaccurate progress updates. Since the progress is set from the Pipe, with the copy, it's really measuring how quickly the files are being copied into the buffer and not how quickly the request body is sent over the wire

Instead of retrying on all requests, only retry when starting a new upload. This is the only time, for now, a request should be retried due to authentication.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/360 **Author:** [@mxyng](https://github.com/mxyng) **Created:** 8/16/2023 **Status:** ✅ Merged **Merged:** 8/17/2023 **Merged by:** [@mxyng](https://github.com/mxyng) **Base:** `main` ← **Head:** `fix-request-copies` --- ### 📝 Commits (2) - [`56e87ce`](https://github.com/ollama/ollama/commit/56e87cecb12907e4283adc7b7d3596f12e491f9d) images: remove body copies - [`9f944c0`](https://github.com/ollama/ollama/commit/9f944c00f1a9c28ae4a2e49675ec9f1f3fc6a48d) push: retry on unauthorized ### 📊 Changes **1 file changed** (+25 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `server/images.go` (+25 -37) </details> ### 📄 Description `makeRequest` makes copies of the request body via bytes.Buffer and bytes.Reader in anticipation of a possible retry. While the memory requirements are negligible for most requests, the copies become significant when pushing a model blob. A sufficiently large model will exhaust all memory on the system causing the process to be kill by the host OS. This copy also produces inaccurate progress updates. Since the progress is set from the Pipe, with the copy, it's really measuring how quickly the files are being copied into the buffer and not how quickly the request body is sent over the wire Instead of retrying on all requests, only retry when starting a new upload. This is the only time, for now, a request should be retried due to authentication. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-24 21:15:39 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#41366