ollama - 💡(How to fix) Fix `ollama ls` takes 5 seconds in interactive terminal (pselect6 timeout on stdout) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15597Fetched 2026-04-17 08:23:31
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Root Cause

Root cause (strace analysis)

Fix Action

Workaround

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

TERM=dumb time ollama ls  # 14ms

Alternatively, pipe output: ollama ls | cat

Code Example

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

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

---

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

---

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

---

TERM=dumb time ollama ls  # 14ms
RAW_BUFFERClick to expand / collapse

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.

extent analysis

TL;DR

The most likely fix is to modify the TUI rendering framework to handle terminal I/O correctly, potentially by adjusting the pselect6 call or implementing an alternative approach to check for fd readiness.

Guidance

  • Investigate the TUI rendering framework (likely bubbletea) to understand why pselect6 is called with a 5-second timeout on stdout fd, and consider adjusting this behavior to reduce the delay.
  • Verify that setting TERM=dumb or piping output eliminates the delay, as this suggests that the issue is related to terminal I/O handling.
  • Review the strace output to understand the sequence of system calls and identify potential areas for optimization or correction.
  • Consider implementing a workaround, such as setting TERM=dumb or piping output, to mitigate the issue until a permanent fix is available.

Example

No code snippet is provided, as the issue is related to the internal implementation of the TUI rendering framework.

Notes

The issue appears to be specific to the TUI rendering framework and its interaction with terminal I/O. The provided strace output and workaround suggestions indicate that the problem is likely related to the pselect6 call and its timeout value.

Recommendation

Apply workaround: setting TERM=dumb or piping output, as this has been shown to eliminate the delay and provide a temporary solution until the underlying issue is addressed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

ollama ls should complete in milliseconds regardless of terminal type.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING