Repository navigation
Conversation
8b4b883 to
53985f9
Compare
a1b7a08 to
e9913d3
Compare
Upstream 8abbc91..2f5abbc (245 commits). Branches rebased onto it: fix/linux-port-scan-inode-cache (#1; now on upstream's linux-proc-net-listeners parser, which gained a uid field), feat/port-detection-setting (#2), feat/remote-autoconnect-setting (#3), feat/reduce-motion-setting (#4), feat/keep-awake-timed (#5), feat/sleep-project-and-group (#6), feat/project-group-filter (#7; group hider composed over upstream's folder-nested exemption), fix/worktree-create-missing-base-hint (#8), ci/fork-build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
e9913d3 to
31e1786
Compare
Upstream 2f5abbc..7bc705a (345 commits). Branches rebased onto it: #1 fix/linux-port-scan-inode-cache, #2 feat/port-detection-setting, #3 feat/remote-autoconnect-setting, #4 feat/reduce-motion-setting, #5 feat/keep-awake-timed, #6 feat/sleep-project-and-group, #7 feat/project-group-filter, #8 fix/worktree-create-missing-base-hint; plus ci/fork-build. - #2: upstream stablyai#43836 took the refreshing flag away from the background scanner; the detection-off reset no longer clears it. - #4: upstream's HoverScrollText and the composer glow use the motion-safe / motion-reduce variants; the bot activity list scrolls with motionSafeScrollBehavior. - #7: kept upstream's bot-listed workspace exclusion next to the project-group scope. Co-Authored-By: Claude Opus 5.5 <[email protected]>
31e1786 to
87a9908
Compare
Upstream 7bc705a..3df243e (480 commits), plus #1-#8 rebased onto it and ci/fork-build. Tree verified with tc + check:changed (42 checks). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Linux port scan mapped listening sockets to pids by reading every fd of every process on the machine, every 30 s, on the main thread. Sockets owned by other users never resolve (their fds are unreadable), so the walk never stopped early. Only resolve sockets whose uid (from /proc/net/tcp) is ours, or all of them when running as root. Remember each socket's owner and reuse it only while that pid still holds the socket, which costs one fd list instead of the whole system. Walk /proc only for sockets without a live owner, from the highest pid down, and stop once all are found: that keeps the old walk's result (the last, i.e. highest, holder) and reaches a new listener's process first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
87a9908 to
3b86c41
Compare
Retires fix/linux-port-scan-inode-cache (#1): upstream stablyai#47943 moved the Linux socket-owner lookup off the main process (one ls in the port-scan worker), which covers what #1 was for. #2 follows upstream stablyai#47994's forward owners (SSH or paired server) in the detection-off panel; its one-off scan guard moved into the store's replaceWorkspacePortScans (workspace-port-actions.ts hit max-lines). #4 routes the new BotItemReplyJump reveal through the Reduce motion helper.
|
Retiring this in favour of upstream stablyai#47943 ("Move the Linux port scan's per-file process lookup off Orca's main process"), merged 2026-11-24 (upstream 2af98f8). Upstream now maps listening sockets to pids with one Upstream tried a reuse cache like this one first and dropped it: a socket handed to a child while its parent lives keeps the cached owner. Keeping this PR on top would bring that back, for a small remaining CPU saving. The branch |
ELI5
To show which dev servers belong to which workspace, Orca checks every 30 seconds which program owns each open port. On Linux it did that by looking through every open file of every program on the computer, each time. Now it skips ports owned by other users (it could never see those anyway), remembers who owned each port, and checks only that program again, unless something new shows up.
What Changed
parseProcNetTcpalso returns the socket'suid(column 8 of/proc/net/tcp).scanLinuxProcPortsonly asks for owners of sockets whose uid is ours, or of all sockets when running as root. Other users' listeners are still listed, without a pid, as before.src/main/ports/linux-listener-socket-owners.tsreplacesmapLinuxInodesToPids:/proc/<pid>/fdread instead of the whole system./procfrom the highest pid down, which stops once all are found.killWorkspacePortuses for Stop authorization return the same pid.The ports list doesn't change. Only the cost of building it does.
Why
On a normal Linux desktop (~1,000 processes) every scan made ~12,300 sequential
readlinkcalls and 1,029readdircalls (555 of them failing with EACCES) on the main thread, to map ~45 listening sockets. About half of those sockets belong to other users (sshd, cupsd, systemd-resolved, …). Their fds are unreadable, so they never resolved, and the walk always covered every process. The main process went from ~2% to 50-65% of a core for ~0.5 s every 30 s.Alternatives considered:
readlinkSyncloop. Less CPU, but it blocks the main thread for tens of milliseconds.Linked Issue
Fork PR. The upstream issue (draft ready) and the PR to
stablyai/orcafollow after review here.Visual Proof
N/A: no UI or interaction change. The ports list shows the same listeners and owners.
Testing
Compared old and new owner resolution side by side on a live Linux desktop over 10 consecutive scans, including a listener that starts and one that exits mid-run: 0 mismatches against the old walk, and the uid filter lost no socket the old code could resolve.
A socket shared by a parent and its forked child resolves to the child (the highest pid), the same as the old walk, on both the first and cached scans.
CPU per scan, same machine and run: steady state 160-210 ms before, ~6 ms after. A new listener: ~170 ms before, 28 ms after. First scan after start: ~200 ms before, 91 ms after.
Measured the main process before the change: ~22-30k read syscalls and a 50-65% spike every 30 s (per-thread
/proc/<pid>/task/<tid>/stat, V8 CPU profile via--inspect).oxlint,oxfmt --check,pnpm test src/main/ports(7 files, 30 passed, 3 macOS-only skipped): all pass.pnpm tc:nodereports one error on currentmainunrelated to this PR:src/main/observability/git-execution-spans.tsimportsshared/rpc-contract/git-admission-tier-params, which refactor(rpc): group request contracts by feature owner stablyai/orca#42063 moved tosource-control/while Attribute Git execution in field traces stablyai/orca#41950 added the import.pnpm check:changed: 22 of 24 checks pass. Both failures happen without this PR: the typecheck error above, andsrc/main/runtime/terminal/launch/wsl-host-agent-launch-paths.test.ts > refuses a Windows-only agent(getsruntime_unavailable), which fails the same way with this commit reverted.Platforms: Linux only. macOS and Windows code paths are untouched.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
No test added: the output is unchanged by design. The only test that would fail on revert counts
/procreads, which the anti-patterns rule out (work counts).Risk
Level: Low
AI Disclosure
Written with Claude Code (Claude Opus 5.5): investigation, profiling and the patch. A separate AI code review pass changed the design (uid filter instead of backoff, highest-pid order). Reviewed and run by the author.
Review
lsof) and Windows (netstat) are untouched.workspace-portsRPC (runtime-workspace-port-operations.ts), so it gets the same change. The protocol and result shape are unchanged, so older paired hosts and clients aren't affected.Agent skill upstream boundary
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code