Skip to content

CPU Usage Increased Significantly in Latest Commit #51

Description

@hjfghycvdt

In commit a8a1bd6, CPU usage was very light, staying below 10%. However, in the latest commit, 279e1f7, CPU usage is considerably higher, as shown below:

Data log monitor

Check 1  ===
========================================

--- crabcode ---
    PID    PPID %CPU %MEM   RSS    VSZ     ELAPSED CMD
  12456       5 50.5  2.9 100240 586952      07:26 crabcode -s obx
========================================
=== Check 2  ===
========================================

--- crabcode ---
    PID    PPID %CPU %MEM   RSS    VSZ     ELAPSED CMD
  12456       5 50.7  2.9 100240 586952      07:29 crabcode -s obx
========================================
=== Check 3  ===                                                  ========================================
                                                                  --- crabcode ---
    PID    PPID %CPU %MEM   RSS    VSZ     ELAPSED CMD              12456       5 50.9  2.9 100240 586952      07:32 crabcode -s obx
========================================
=== Check 4  ===
========================================

--- crabcode ---
    PID    PPID %CPU %MEM   RSS    VSZ     ELAPSED CMD              12456       5 51.1  2.9 100240 586952      07:35 crabcode -s obx
========================================
=== Check 5  ===
========================================

--- crabcode ---
    PID    PPID %CPU %MEM   RSS    VSZ     ELAPSED CMD
  12456       5 51.3  2.9 100240 586952      07:38 crabcode -s obx
========================================
=== Check 6  ===
========================================

--- crabcode ---
    PID    PPID %CPU %MEM   RSS    VSZ     ELAPSED CMD
  12456       5 51.5  2.9 100240 586952      07:41 crabcode -s obx
========================================
=== Check 7  ===
========================================

--- crabcode ---
    PID    PPID %CPU %MEM   RSS    VSZ     ELAPSED CMD
  12456       5 51.6  2.9 100240 586952      07:44 crabcode -s obx
========================================

Hopefully, CPU usage can be optimized further in the next version.

Activity

  1. yan-ad commented on Sep 9, 2026

    @yan-ad
    Contributor

    I investigated this and could not reproduce the idle CPU regression on the current main, or on the two commits in the report.

    I launched the exact session form, crabcode -s obx, in a PTY, waited 5 seconds, then sampled CPU for 6 seconds:

    • a8a1bd6: 2.6%, 0.1%, then 0.0% for the remaining samples (0.45% mean)
    • 279e1f7: 1.5%, 0.2%, then 0.0% for the remaining samples (0.28% mean)
    • current main: 0.0% across all 8 samples after the same 5-second settle period

    The home-screen animation is intentionally stopped after 3 seconds of inactivity, and the event loop then blocks for up to 30 seconds awaiting terminal input.

    Could you share the OS/distribution, terminal emulator, exact release/binary (crabcode --version), and whether the session is still actively streaming or has background jobs running when sampled? The ps %CPU output strongly suggests a 20 Hz redraw loop is still active, but I need that state to identify which condition is keeping it awake.

  2. hjfghycvdt commented on Sep 10, 2026

    @hjfghycvdt
    Author

    I investigated this and could not reproduce the idle CPU regression on the current main, or on the two commits in the report.

    I launched the exact session form, crabcode -s obx, in a PTY, waited 5 seconds, then sampled CPU for 6 seconds:

    • a8a1bd6: 2.6%, 0.1%, then 0.0% for the remaining samples (0.45% mean)
    • 279e1f7: 1.5%, 0.2%, then 0.0% for the remaining samples (0.28% mean)
    • current main: 0.0% across all 8 samples after the same 5-second settle period

    The home-screen animation is intentionally stopped after 3 seconds of inactivity, and the event loop then blocks for up to 30 seconds awaiting terminal input.

    Could you share the OS/distribution, terminal emulator, exact release/binary (crabcode --version), and whether the session is still actively streaming or has background jobs running when sampled? The ps %CPU output strongly suggests a 20 Hz redraw loop is still active, but I need that state to identify which condition is keeping it awake.

    I compiled it myself using the latest commit. When I checked the CPU usage after some chats, maybe 3–7 chats, the CPU usage was quite high.

    CrabCode 0.0.12
    OS: Android 13 (Termux latest beta)
    OS: Debian Trixie ARM64 on TV Box (Amlogic S905X)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions