Skip to content

[HAS FIX] Improve detach latency and responsivenes #323

@tobwen

Description

@tobwen

Summary

When detaching from a shpool session, users experience noticeable latency (100 to 300ms delay) and slow responsiveness. The detach operation uses conservative polling intervals that cause threads to stay blocked waiting for poll cycles, making the detach feel sluggish.

The polling intervals (100ms for thread joins and shell->client communication) are too conservative, causing noticeable delay between issuing detach and the operation completing.

Current limitation

# Detach is noticeably slow
$ shpool attach mysession
# ... work ...
# Ctrl+D to detach
# (noticeable 100-300ms delay before detach completes)

Impact

  • Users experience sluggish detach behavior
  • Threads stay blocked waiting for poll cycles after detach
  • Degraded user experience when switching between sessions
  • Makes shpool feel less responsive compared to native terminal detach

Changes

  • Reduce polling intervals from 100ms to 10ms for faster thread joins
  • Reduce shell->client polling from 100ms to 10ms for faster detach detection
  • Implement adaptive backoff (1ms initial, exponential to 25ms max) to avoid busy waits
  • Add fast path for TTY detach (10ms) vs slow path fallback (300ms max)
  • Exit client->shell thread immediately after detach action
  • Check stop flag during polling intervals for faster responsiveness

PR

#324

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions