Skip to content

st2 ding consumes ~60% CPU while waiting on an idle inbox #22

Description

@schickling-assistant

Summary

The st2 ding sidecar appears to spin or poll aggressively while waiting for inbox activity. In a deployment with no sustained message traffic, one sidecar averaged about 60% of one CPU core for more than 72 minutes.

This report intentionally anonymizes the host, account, catalog paths, agent identities, and project names. The numeric process evidence is retained.

Related issue

Version

  • st2 0.1.0
  • build commit: 46ff6ee
  • Linux, x86_64

Reproduction

  1. Start a persistent PTY for an agent and ensure its inbox is empty.

  2. Start the sidecar:

    st2 ding \
      --identity example-agent \
      --root /tmp/example/catalog
  3. Do not send messages and leave the agent status unchanged.

  4. Measure the sidecar:

    pid=$(pgrep -n -f 'st2 ding')
    pidstat -p "$pid" 1 60
    ps -Lp "$pid" -o pid,lwp,etimes,stat,pcpu,comm,wchan
    cat "/proc/$pid/io"
    grep -E 'Threads|voluntary_ctxt|nonvoluntary_ctxt' "/proc/$pid/status"

Observed in a long-running deployment

After 4,346 seconds:

STAT  %CPU  RSS    threads  voluntary switches  involuntary switches
Rsl   59.6  5 MiB  2        2,276,158           39,686,551

/proc/<pid>/io:

rchar: 3,209,458,431
wchar: 8,620
syscr: 434,210,543
syscw: 62
read_bytes: 602,112
write_bytes: 65,536

The very high syscall and involuntary-context-switch counts are disproportionate to an idle inbox watcher.

Expected

With no inbox changes, the sidecar should block on a filesystem notification or a low-frequency timer and consume near-zero CPU.

Suggested investigation

  • Check the watch loop for nonblocking reads or immediate retry paths.
  • Check whether presence/status reads are performed continuously while idle.
  • Add metrics for watcher wakeups, directory scans, deferred-message checks, and PTY probes.
  • Add an idle-load test that asserts bounded syscalls and CPU time over 30–60 seconds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:dingDING delivery: inbox notice into a running agent · Set: manualorigin:agentFiled or primarily produced by an AI agent · Set: manualtype:bugSomething broken or a regression · Set: manual

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions