[GH-ISSUE #15597] ollama ls takes 5 seconds in interactive terminal (pselect6 timeout on stdout) #87642

Open
opened 2026-05-10 06:11:58 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @felix021 on GitHub (Apr 15, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/15597

Describe the bug

ollama ls (and other list/ps commands) consistently takes exactly 5 seconds when run in an interactive terminal (PTY). The same command completes in ~14ms when stdout is piped or not connected to a TTY.

Steps to reproduce

  1. Run time ollama ls in any interactive terminal (xterm, tmux, gnome-terminal, etc.)
  2. Observe ~5 second delay before output appears

Reproducible via script which creates a PTY:

# Slow (5s) - with PTY
script -qc 'time ollama ls' /dev/null

# Fast (14ms) - without PTY
time ollama ls | cat

Expected behavior

ollama ls should complete in milliseconds regardless of terminal type.

Root cause (strace analysis)

strace -f -T shows the TUI rendering framework performs a pselect6 on stdout (fd 1) with a 5-second timeout:

pselect6(2, [1], NULL, NULL, {tv_sec=5, tv_nsec=0}, NULL) = 1 (in [1])       # first call succeeds
pselect6(2, [1], NULL, NULL, {tv_sec=5, tv_nsec=0}, NULL) = 0 (Timeout) <5.005162>  # second call times out

After the 5s timeout, the process proceeds normally:

ioctl(1, TCSETS, ...)  # terminal control
SIGURG                  # Go runtime signal

The 5-second wall time is entirely I/O wait (user=7ms, sys=14ms, real=5020ms).

Workaround

Setting TERM=dumb bypasses the TUI rendering and eliminates the delay:

TERM=dumb time ollama ls  # 14ms

Alternatively, pipe output: ollama ls | cat

Environment

  • OS: Ubuntu 24.04, Linux 6.8.0-107-generic
  • Ollama: v0.18.2
  • GPU: NVIDIA GeForce RTX 5060 Ti (driver 590.48.01, CUDA 13.1)
  • Terminal: Reproduced in gnome-terminal, tmux, and via script -qc
  • Shell: bash 5.2

Additional context

The issue is not related to network/proxy configuration (verified by testing with and without proxy). It is purely a terminal I/O issue in the CLI's TUI framework (likely bubbletea). The pselect6 on stdout fd behavior suggests a race condition or incorrect fd readiness check in the terminal rendering pipeline.

Originally created by @felix021 on GitHub (Apr 15, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/15597 ## Describe the bug `ollama ls` (and other list/ps commands) consistently takes exactly **5 seconds** when run in an interactive terminal (PTY). The same command completes in ~14ms when stdout is piped or not connected to a TTY. ## Steps to reproduce 1. Run `time ollama ls` in any interactive terminal (xterm, tmux, gnome-terminal, etc.) 2. Observe ~5 second delay before output appears Reproducible via `script` which creates a PTY: ```bash # Slow (5s) - with PTY script -qc 'time ollama ls' /dev/null # Fast (14ms) - without PTY time ollama ls | cat ``` ## Expected behavior `ollama ls` should complete in milliseconds regardless of terminal type. ## Root cause (strace analysis) `strace -f -T` shows the TUI rendering framework performs a `pselect6` on stdout (fd 1) with a 5-second timeout: ``` pselect6(2, [1], NULL, NULL, {tv_sec=5, tv_nsec=0}, NULL) = 1 (in [1]) # first call succeeds pselect6(2, [1], NULL, NULL, {tv_sec=5, tv_nsec=0}, NULL) = 0 (Timeout) <5.005162> # second call times out ``` After the 5s timeout, the process proceeds normally: ``` ioctl(1, TCSETS, ...) # terminal control SIGURG # Go runtime signal ``` The 5-second wall time is entirely I/O wait (`user=7ms, sys=14ms, real=5020ms`). ## Workaround Setting `TERM=dumb` bypasses the TUI rendering and eliminates the delay: ```bash TERM=dumb time ollama ls # 14ms ``` Alternatively, pipe output: `ollama ls | cat` ## Environment - **OS**: Ubuntu 24.04, Linux 6.8.0-107-generic - **Ollama**: v0.18.2 - **GPU**: NVIDIA GeForce RTX 5060 Ti (driver 590.48.01, CUDA 13.1) - **Terminal**: Reproduced in gnome-terminal, tmux, and via `script -qc` - **Shell**: bash 5.2 ## Additional context The issue is not related to network/proxy configuration (verified by testing with and without proxy). It is purely a terminal I/O issue in the CLI's TUI framework (likely bubbletea). The `pselect6` on stdout fd behavior suggests a race condition or incorrect fd readiness check in the terminal rendering pipeline.
Author
Owner

@PureBlissAK commented on GitHub (Apr 18, 2026):

🤖 Automated Triage & Analysis Report

Issue: #15597
Analyzed: 2026-04-18T18:19:33.608983

Analysis

  • Type: unknown
  • Severity: medium
  • Components: unknown

Implementation Plan

  • Effort: medium
  • Steps:

This issue has been triaged and marked for implementation.

<!-- gh-comment-id:4274305108 --> @PureBlissAK commented on GitHub (Apr 18, 2026): <!-- ollama-issue-orchestrator:v1 issue:15597 --> ## 🤖 Automated Triage & Analysis Report **Issue**: #15597 **Analyzed**: 2026-04-18T18:19:33.608983 ### Analysis - **Type**: unknown - **Severity**: medium - **Components**: unknown ### Implementation Plan - **Effort**: medium - **Steps**: *This issue has been triaged and marked for implementation.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#87642