Repository navigation
Description
thirdshift console (0.14.3) burns 50-74% of one core on stephens.page with no Console tabs open. Over 33h46m of uptime the thirdshift-console.service process (PID 3393557) accumulated 7h38m of CPU time, a steady ~22% of a core averaged over its life on a 4-core host.
Evidence
-
pidstat5s samples at 2026-10-23 13:13-13:20 UTC: 51%, 74%, 60% CPU. Roughly 60% of that is system time (e.g. 35.6% sys vs 24.4% usr), split across tokio-rt-worker threads. -
4 established connections to 127.0.0.1:8711 from the Apache proxy for
console.stephens.page. After I closed every Console tab in Chrome, CPU did not drop and 2 of the 4 connections were replaced by new ones, so the load does not track open browser tabs. -
Restarting does not clear it. After
sudo systemctl restart thirdshift-consoleat 13:19 UTC, the new process (PID 2591794) sampled 64.5% CPU (26.9% usr, 37.6% sys) over its first 10s and had used 28s of CPU in 47s of uptime, with 3 proxy connections open. The spin starts at launch rather than building up over the process's life, which should make it easy to reproduce. -
thirdshift console logshows only sign-in, code-sent and password-set entries, nothing that accounts for the activity. -
/proc/<pid>/ioover 5s after the restart: 87 MBrcharacross 54,342readsyscalls (about 17 MB/s and 11k reads/s, all from page cache,read_bytes0) and 5.3 MBwchar(about 1 MB/s out to the proxy connections). That is where the system time goes. -
300 samples of
/proc/<pid>/fdmostly caught the process holding directories under~/.thirdshift/logs/*/*/commands/*open, led byJacobStephens2/thirdshift/commands/pickup(445 MB) andJacobStephens2/keeplore/commands/architect(725 MB). The whole store is 6.4 GB across 5,366 files.
Likely causes (at 380e63a)
Every one of these is a fixed-interval poll rather than a reaction to a change:
src/console/live.rs:13-29-observe()re-renders the whole Inbox page every 1s and diffs the HTML, whether or not anyone is viewing. This explains the spin starting at launch.src/console/live.rs:40-58- each live connection runsstill_allowed()on a blocking thread every 250ms.src/console/logs.rs:220-222- each open log reader re-reads its log every 250ms.src/console.rs:322-335- the shutdown watcher reloads the accounts file every 250ms.
A one-off thirdshift status takes 0.10s (0.04 usr, 0.03 sys), so a 1Hz render alone should cost about 10% of a core, not 60%. Either render_page does far more than the CLI (likely walking the log store) or the per-connection loops make up the rest. Profile before changing code, and confirm the fix against the same measurements.
Scope
- Fix all four polling loops above, not only the Inbox observer.
- Switching to change-driven updates (filesystem notifications such as the
notifycrate, or signals from the code that writes Command logs and account state) is in scope and preferred over tuning intervals. Keep a slow fallback poll only if notifications can be missed. - Bounding the log store itself is out of scope and tracked in Command log store grows without bound (6.4 GB on stephens.page) #1155. The fix here has to hold at the current 6.4 GB.
Expected
An idle Console with no viewers should sit near 0% CPU, and CPU with viewers connected should scale with actual state changes, not with time.
Workaround
None short of sudo systemctl stop thirdshift-console, which takes the Console offline. Restarting does not help (see above). Stopping or restarting the service does not affect running thirdshift Runs, since they live outside the service's cgroup.
Acceptance criteria
- Root cause identified with a profile or syscall/IO measurement, recorded in the PR
- With no viewers connected,
thirdshift consoleaverages under 1% of one core over 60s on stephens.page (6.4 GB log store) - With 3 viewers connected (Inbox open, one log reader open) and no Runs changing state, it averages under 5% of one core over 60s
- With no viewers and no state changes,
rchargrows by under 1 MB per minute - Inbox and log readers still update within about 2s of a change, and a removed account still loses its sessions without a request
- Tests cover the change-driven update path
Activity
JacobStephens2 commentedon Oct 23, 2026
Triage findings: reproduced on a second host, likely cause found
Reproduced with zero viewers
This is the
thirdshifthost (Caddy in front, not stephens.page), runningthirdshift-console.serviceon 0.14.3, PID 4139545, up 2d14h.pidstat5s samples at 2026-10-23 13:20 UTC: 49.6%, 46.8%, 39.4%, about 55/45 usr/sys. Most of it is on twotokio-rt-workerthreads, each around 16%.ss -tn state established '( sport = :8711 or dport = :8711 )'is empty). The load doesn't depend on viewers./proc/4139545/io: lifetimercharis 2.4 TB, about 10.7 MB/s on average, from about 2,100 read syscalls/s. A live 5s sample showed about 4 MB/s and 1,100 reads/s.Likely cause: the Inbox observer re-renders every second, and each render re-reads the logs
src/console/live.rsobserve()starts a task when the server starts. That task callsrender_inbox("thirdshift status")every 1s, whether or not anyone is subscribed. It diffs the HTML to decide whether to bump thewatchrevision.render_inbox→render_page→status::inbox(&config)(src/console.rs:482) rebuilds the whole Inbox from disk each time.To measure what one render costs, I traced the equivalent CLI,
thirdshift status:readand 206getdents64calls.logs/<owner>/<repo>/activity.log(500 KB for thirdshift, 290 KB for chart35, 220 KB for muxboard and so on) and completecommands/{issue,pickup}/*.logfiles of 200–300 KB each.~/.thirdshift/logsholds 3,460 files, 4.4 GB. Per-tick cost grows as Runs pile up, which fits both hosts getting worse over time.The reads are served from page cache, which explains the high system-time share (kernel copy work). On an 8 GB host it also keeps several GB of logs hot in cache.
Smaller periodic work
src/console.rs:323-338: every 250ms it stats the executable (restart::Executable::changed). When sign-in is enabled it also callsspawn_blocking(Accounts::load), which reloadsconfig.toml, takesconsole-accounts.lockand parsesconsole-accounts.json. That's 4 times a second with no viewers.src/console/live.rs:40-56: each open/eventsstream runsspawn_blocking(still_allowed)every 250ms. This doesn't apply to the idle case above, but it is a fixed per-viewer cost that doesn't depend on state changes (acceptance criterion 3).Gap I couldn't close
At 1 Hz, one CLI-equivalent render accounts for about 10% of a core. The observed 40–50% is higher than that.
ptraceandperfon the service process were denied, so I couldn't profile it directly. Things to check: whether the Console's render reads more than the CLI path (template plus hidden sections), and how much the 4 HzAccounts::loadloop costs. A profile (perf record -p <pid>as root, orstrace -c -f -p <pid>as root) would settle it.Suggested fix direction
~/.thirdshift/logswith inotify/notify, or check cheap mtimes/sizes first and only re-render on a change. At minimum, skip rendering whenchanges.receiver_count()shows no subscribers.status::inboxstop reading wholeactivity.logand command logs on every call: tail or seek to what it needs, or cache parsed state keyed by (path, len, mtime).console-accounts.jsonandconfig.toml.Recommendation
Category
bug(already applied). Stateready-for-agent: the cause is located and the acceptance criteria are measurable (pidstat//proc/<pid>/ioon an idle service). Left atneeds-triageuntil the maintainer confirms.JacobStephens2 commentedon Oct 23, 2026
A third host, with a root syscall profile
thirdshift-console.service0.14.3, behind Apache (httpd), up 1d19h56m. This host has 8 cores and 15 GB of RAM. Its log store is much smaller: 166 MB across 498 files (vs 6.4 GB on stephens.page). Measured 2026-10-23 13:33–13:36 UTC.CPU and IO
/proc/<pid>/stat, sampled every 10s: 20%, 18%, 21%, 20%, 18%, 17% of one core. That's 18.7% overall, 69/31 usr/sys./proc/<pid>/io:rchargrew 133 MB (2.2 MB/s) over 84,482readcalls (about 1,400/s).read_bytesstayed at 0, so all of it came from page cache.wchargrew 14.8 MB.rcharis 228 GB.tokio-rt-workerthreads.So the cost holds even with a small store. It scales with the number of Command records in a directory, not the store's byte size.
strace -c -f, 20s, as root
Most of the wall time is in
futexandepoll_pwait, which is idle waiting. The work is directory listing and opening small files.What it opens: 6,836 open/stat calls in 10s
logs/<org>/<repo>/commands/pickup/*.json(276 files in the dir)commands/pickupdirectory itself<repo>/commands/issue/*.json(126 files)<repo>/commands/architect/*.json(31 files)<repo>/commands/{pickup,issue}/*.logissue/architectdirectoriesJacobStephens2/thirdshift/commands/issue/*.jsonconfig.tomlconsole-accounts.json/console-accounts.lockThe
commands/pickupdirectory is listed about 109 times a second, and its Command records are opened about 274 times a second. That is far more often than the 1 Hz Inbox observer alone would cause. It points to the per-connection 250ms loops (still_allowed, log readers) or to listing being repeated inside a single render, for example once per Command or per Run instead of once per directory. The 300-sample/proc/<pid>/fdcapture agrees: the directory most often held open was<repo>/commands/pickup.Writes nobody asked for
console-accounts.jsonis rewritten about every 2s (temp file +fsync+renameatinto~/.thirdshift/console-accounts.json), while the page is only being watched (9 proxy connections, no sign-ins in the measurement window). Something in the session or still-allowed path seems to persist on read. That also makes the 250ms watchers' reload of that file self-inflicted churn.mkdir("~/.thirdshift")runs about 8 times a second, always with EEXIST, which suggests the directory is created on every config or account load.These are worth adding to the fix scope. An idle Console should write nothing.
JacobStephens2 commentedon Oct 23, 2026
Same host, after
sudo systemctl stop thirdshift-console.serviceStopped at 2026-10-23 13:39 UTC, using the workaround from the issue body.
inactive(main process exit status 15, SIGTERM). Nothirdshift consoleprocess is left, and nothing is listening on 127.0.0.1:8711. Requests through the proxy now fail, as expected.CPUUsageNSecis 15,775s, or 4h23m of CPU across its 1d20h life, about 10% of a core on average. Between the first reading at 13:32:46 and the stop it used another 80s, about 21% of a core over those 6½ minutes. That window includesstraceoverhead.thirdshiftprocess was running at the time of the stop, so no Run was affected.rustcbuild, so the drop from the Console (about 0.2 core of 8, roughly 2.5% of the host) is within that noise. The before figures in the previous comment were measured on the Console process alone, and they're the ones to compare a fix against.To check the fix on this host, restart the fixed binary with the same 9-ish proxy connections, then repeat the 60s
/proc/<pid>/statand/proc/<pid>/iosamples and thestrace -c -fprofile. The aim is under 1% of a core,rcharunder 1 MB/min, and norenameatintoconsole-accounts.jsonwhile idle.JacobStephens2 commentedon Oct 23, 2026
Code findings at 380e63a, plus a fourth host
These are the causes the earlier comments left open. Each one points to code.
Why
console-accounts.jsonis rewritten every ~2sOn every signed-in request, the auth middleware calls
Accounts::load()?.session(&selected, true)(src/console/auth.rs:107). Withtouchset,session()updates the session's last-use time and callssave(): a temp file,fsync, then a rename overconsole-accounts.json(src/console/accounts.rs:198-213,241-247). So every page fetch writes to disk. Sessions last 30 days, so the last-use time only needs persisting when it is more than about a minute old.Where the
mkdirEEXIST calls andconfig.tomlreads come fromAccounts::openrunsfs::create_dir_all(root)on every load (accounts.rs:97).Accounts::loadalso runsUserConfig::load()each time. Accounts are loaded:console.rs:323-335)still_allowed()in every Inbox stream, 4 times a second (live.rs:42)logs.rs:201)auth.rs:107)That fits the 106 reads of
config.tomlper 10s in the root profile.Every render reads the whole store, not just the Inbox window
Snapshot::load_with_silence(src/logs/reading.rs:43-100) lists and parses every*.command.jsonand*.child.jsonin every repo.inbox_daysis only applied afterwards, insnapshot.inbox(false, config.inbox_days)(src/logs/status/inbox.rs:201-202). The cost of each render therefore grows with the total number of records, which #1155 is what lets grow. A fix that holds without #1155 needs either a parse cache keyed on (path, mtime, len) or loading only the records the Inbox window needs. Making the observer change-driven alone isn't enough, because each change still costs a full-store parse.The browser multiplies each change
Every
commandsevent makes each subscriber in a tab refetch/: the page refresh (assets/console.js:136) and the notifications check (assets/notifications.js:35). Each fetch is a full server render plus an accounts save (see above). If the event stream errors,assets/changes.jsalso falls back to refetching every 5s. With viewers connected, one state change therefore costs several full renders per tab. Keep this in mind when measuring acceptance criterion 3.A small correction on threads
The Console builds a
new_current_threadruntime (console.rs:308). The busytokio-runtime-workerthreads in the measurements are therefore thespawn_blockingpool. The time goes into the blocking closures (rendering and account loads), not the async scheduler.Fourth host: orchestration.etadventures.com
thirdshift-console.service0.14.3, up 23h, no established connections to 127.0.0.1:8711. The log store is 56 MB with 94.jsonfiles, on 8 cores.rcharabout 37 MB/min.rcharis 51.7 GB.This is the same bug at a smaller size. It agrees with the third host that the cost scales with the number of records, not the store's byte size.
Still open
Nobody has yet attributed the "
commands/pickuplisted about 109 times a second" figure. The per-viewer 250ms loops, the per-request account loads and the browser's extra refetches together look like enough to explain it, but that is unmeasured. Thestraceprofile on the fixed build should confirm it.