[PR #15532] runner: avoid full pending joins for stop checks #20413

Open
opened 2026-04-16 07:37:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15532
Author: @vonbai
Created: 4/13/2026
Status: 🔄 Open

Base: mainHead: goalx/pending-stop-piece-checks


📝 Commits (2)

  • cf01eb9 runner: avoid full pending joins for stop checks
  • dbf2dc2 runner: preserve stop priority in piece checks

📊 Changes

4 files changed (+247 additions, -9 deletions)

View changed files

📝 runner/common/stop.go (+89 -0)
📝 runner/common/stop_test.go (+152 -0)
📝 runner/llamarunner/runner.go (+3 -4)
📝 runner/ollamarunner/runner.go (+3 -5)

📄 Description

Summary

  • Avoid repeatedly joining the full pending response buffer when checking stop strings in the runner hot path.
  • Add piece-aware stop matching helpers and regression coverage for stop-list priority across piece boundaries.
  • Preserve existing runner behavior while reducing avoidable allocation/work in the common pending-response check.

Validation

  • go test ./runner/common ./runner/llamarunner ./runner/ollamarunner
  • go test ./runner/common -run '^$' -bench '^BenchmarkPendingStopChecks$' -benchmem -count=1

Benchmark on my machine:

  • join: 3325 ns/op, 2048 B/op, 1 allocs/op
  • pieces: 279.0 ns/op, 88 B/op, 6 allocs/op

🔄 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/15532 **Author:** [@vonbai](https://github.com/vonbai) **Created:** 4/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `goalx/pending-stop-piece-checks` --- ### 📝 Commits (2) - [`cf01eb9`](https://github.com/ollama/ollama/commit/cf01eb91e9841f96ed0080a5bb1d142384ca6437) runner: avoid full pending joins for stop checks - [`dbf2dc2`](https://github.com/ollama/ollama/commit/dbf2dc215bda6af1770a4e4658b9a2c05cba002b) runner: preserve stop priority in piece checks ### 📊 Changes **4 files changed** (+247 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `runner/common/stop.go` (+89 -0) 📝 `runner/common/stop_test.go` (+152 -0) 📝 `runner/llamarunner/runner.go` (+3 -4) 📝 `runner/ollamarunner/runner.go` (+3 -5) </details> ### 📄 Description ## Summary - Avoid repeatedly joining the full pending response buffer when checking stop strings in the runner hot path. - Add piece-aware stop matching helpers and regression coverage for stop-list priority across piece boundaries. - Preserve existing runner behavior while reducing avoidable allocation/work in the common pending-response check. ## Validation - `go test ./runner/common ./runner/llamarunner ./runner/ollamarunner` - `go test ./runner/common -run '^$' -bench '^BenchmarkPendingStopChecks$' -benchmem -count=1` Benchmark on my machine: - `join`: `3325 ns/op`, `2048 B/op`, `1 allocs/op` - `pieces`: `279.0 ns/op`, `88 B/op`, `6 allocs/op` --- <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-16 07:37:05 -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#20413