• SVDM: High idle CPU usage

    From xbit ops@1:103/705 to GitLab issue in main/sbbs on Thu Jun 25 17:13:37 2026
    open https://gitlab.synchro.net/main/sbbs/-/issues/1176

    SVDM appears to use roughly 12–15% total CPU while SF is idle and waiting for calls. That is close to one logical CPU remaining busy. Test with Debug=false and normal logging, then document idle, connected-idle, and active-call CPU usage.

    ![image](https://gitlab.synchro.net/-/project/13/uploads/c42f172cefa9ef1b58428580a7ec3480/image.png){width=670 height=53}
    --- SBBSecho 3.37-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Wed Sep 30 15:30:54 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1176#note_10548

    The CPU use comes from SVDM's main loop in `src/vdmodem/vdmodem.c`, which never blocks with the default settings:

    - **Idle, waiting for a call:** the loop waits on the DOS process handle with a timeout of `MainLoopDelay`, which defaults to 0. So it returns immediately, polls the mailslot and ring state, and spins one logical CPU at 100%. On an 8-thread machine that shows as the 12-15% total in the screenshot.
    - **Connected but idle:** the socket `select()` timeout is `SocketSelectTimeout`, which also defaults to 0, so the loop still spins.
    - **Active call with a `Rate` set:** while received data waits for the rate-pacing interval, `select()` returns immediately every pass. Even with both settings raised, the loop spins until that interval passes.

    Both settings were added in 5fd72f315e (2024-03-25) as opt-in knobs with a default of 0.

    **Workaround for the current build:** add `MainLoopDelay=1` (and optionally `SocketSelectTimeout=1`) to the root section of `svdm.ini`. Idle CPU should drop to near zero.

    **Fix in progress (SVDM v0.7, not yet committed):** every pass of the main loop now blocks somewhere:
    - **Idle / command mode:** it waits on the process handle for at least 1 ms.
    - **Online:** it blocks in `select()` for `SocketSelectTimeout` (new default: 1 ms). Incoming network data still wakes it immediately.
    - **Rate pacing:** it waits out the remaining pacing interval instead of spinning.

    An explicit `SocketSelectTimeout=0` restores the old spin-wait behavior for anyone who wants it. Data from the DOS program is still polled from the mailslot, so its added latency is at most one Windows timer tick (about 15 ms).

    @xbit, once a build is available, could you report idle, connected-idle and active-call CPU usage with `Debug=false`?

    — *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Wed Sep 30 23:46:22 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1176#note_10586

    Fixed in 452932d563 (SVDM v0.7). Changes from the earlier description: the timer resolution is raised to 1 ms for the duration of the main loop so the waits aren't rounded up to the ~15 ms default tick (that also keeps the emulated `DataRate` pacing accurate), and while rate-limited the loop waits 1 ms and re-checks rather than sleeping out the whole pacing interval, so DOS-program output and DTR drops are still serviced every millisecond.

    @xbit, once you have a build with this change, could you report idle, connected-idle and active-call CPU usage with `Debug=false`?

    — *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From xbit ops@1:103/705 to GitLab note in main/sbbs on Thu Oct 1 01:29:03 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/1176#note_10588

    CPU usage now normal

    ![image](/uploads/17c28a7c8872de0aef8884ba1712b9b8/image.png){width=712 height=109}
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From xbit ops@1:103/705 to GitLab issue in main/sbbs on Thu Oct 1 01:29:16 2026
    close https://gitlab.synchro.net/main/sbbs/-/work_items/1176
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)