Repository navigation
tailscale: virtualize the machine list so huge tailnets don't melt the shell - #7623
Conversation
On a corporate tailnet with ~3,900 machines the tailscale widget makes the shell unusable: `tailscale status --json` is ~4.6MB, and every 30s poll reassigns `peers`, rebuilding one eager row per peer - each with its own copy-menu Popup - on every bar. That is ~500k QML object creations per refresh: ~4.6s of shell CPU per poll, ~15% average CPU, multi-second main-thread stalls, and delegate trees that ratchet RSS into the gigabytes over a workday. Rebuild the hot paths so tailnet size stops mattering: - Render machines through a clipped, virtualized ListView (reuseItems) instead of a Repeater in a Column, so only the visible rows exist. - Add a search field over the machines (`/` focuses it, Escape clears), with the match count in the section header - a 4k-row list is not scrollable without one. - Share one copy-menu Popup across rows instead of instantiating one per peer. - Only reassign peers/exitNodes/mullvadRegions when their content actually changed, so an unchanged poll rebuilds nothing. - Poll with --peers=false (~3KB) while the panel is closed; fetch the full peer list on panel open and explicit refresh. Measured on a 3,933-peer tailnet with two bars: a full refresh drops from ~4.6s of shell CPU (plus ~7MB retained) to ~0.17s, steady state from ~15% average CPU to under 1%, and RSS holds at ~520MB instead of climbing past 7GB. Keyboard navigation, the copy menu, taildrop send, and small-tailnet behavior are unchanged; the cursor and copy actions operate on the filtered list. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Optimizes the Tailscale panel for large tailnets through virtualization and lighter polling.
Changes:
- Adds virtualized, searchable peer lists.
- Shares copy-menu state and avoids unchanged array updates.
- Uses lightweight polling while the panel is closed.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
Service.qml |
Adds change detection and conditional peer fetching. |
Panel.qml |
Adds search, list virtualization, and shared copy popup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| _statusFullPeers = fullPeers === true || peersWanted | ||
| statusProcess.command = _statusFullPeers | ||
| ? ["tailscale", "status", "--json"] | ||
| : ["tailscale", "status", "--json", "--peers=false"] |
There was a problem hiding this comment.
Good catch — fixed in 97b37c3: a full-peer request that arrives while a light poll is in flight is now remembered (_pendingFullPeers) and launched from statusProcess.onExited, so an opened panel never waits out the refresh interval.
| function openCopyMenuFor(peer, row) { | ||
| if (!peer || copyOptionsFor(peer).length === 0) return | ||
| copyPeer = peer | ||
| clampCopyIndex() |
There was a problem hiding this comment.
Fixed in 97b37c3: openCopyMenuFor now resets copyIndex whenever the menu opens for a different peer, matching the old per-row behavior.
…py cursor Review follow-ups: a full-peer request that arrived while a --peers=false poll was still running was silently dropped, leaving a freshly opened panel stale for up to a whole refresh interval - remember it and launch the full fetch when the light process exits. And the shared copy menu kept the cursor position from the previous machine's menu, so Enter could copy an unexpected field - reset it whenever the menu opens for a different peer. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Reviewed on a disposable VM running this branch's shell ( The virtualization itself holds up. Two things worth fixing before this lands. 1. The list jumps back to the top on every poll that changes anything. (Panel.qml:829)
On a small tailnet the list never scrolls, so it does not bite. On the 4k tailnet this PR exists for, peers flip 2. A search query can outlive its search field. (Panel.qml:771-798)
Smaller, same area:
On the Service half: Second opinion. Its top finding I checked and rejected. It reported as High that Scope. The virtualization and the shared popup are proportionate: the popup had to move, or it would have been per-row state inside a recycled delegate. The search field is scope creep, but a 4000-row list needs it. The Service-side light polling is a second, separable change with its own risk — the stale/empty first open above — and would read better as a follow-up; Overlap. #7332 caps and independently scrolls the same machine list while keeping the eager Nothing pushed to your branch. The two main items are judgement calls about how the model is published and how search should persist, which are yours rather than mine, and |
…edges Review follow-ups. Qt resets contentY whenever a JS-array model is reassigned, and on a large tailnet any poll where a peer changed publishes a new array - so the machine list scrolled itself to the top under the user's finger, roughly every refresh while the panel was open. Remember the position the user (or keyboard cursor) chose and restore it on model change; filter changes and panel opens reset it explicitly. Also: clear the search query when its field disappears (small-tailnet account switch) or the panel closes, so an invisible filter cannot hide machines; make showPeers filter-aware so the keyboard cursor cannot enter a section that renders nothing; consume Up in the search field instead of letting it move the section cursor; show "Loading machines" rather than "No machines found on this tailnet." before the first full peer fetch has answered; and publish mullvadExitNodes unconditionally so it cannot go stale behind the regions signature guard. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Thanks — this is a genuinely useful review, especially the measured model-reset behaviour. All five items addressed in d3a35fd:
Also took the nit: On the On scope: agreed the light polling would have been cleaner as a follow-up — the PR's steady-state numbers depend on it, which is why it's here. If splitting it out makes this easier to take, say the word and I'll carve it into its own PR. Same for the #7332 overlap — maintainer's call, this PR touches the same lines and subsumes the cap-and-scroll approach. |
peersLoaded was set on every full status parse and only ever cleared by resetUnavailable, which a normal stop/start never reaches: `tailscale down` parses fine and exits zero, so it lands in the light-poll branch that clears peers and leaves the flag set. Stop Tailscale, start it again while the panel is closed so only light polls observe the transition, and the next open has peers empty with peersLoaded still true — the panel then states "No machines found on this tailnet." for the whole of the full fetch, which is the claim peersLoaded was added to avoid. Tie the flag to what it names instead: a full poll sets it only when the tailnet is actually running, and the light-poll branch that clears peers clears it too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]>
|
Re-reviewed at d3a35fd. All five items are fixed. I checked each by mechanism rather than by description: on a disposable VM running this branch's shell against a stub 4000-machine tailnet, plus two compiled Qt 6.11.2 probes for the questions a screenshot cannot answer. The scroll fix holds. This was the one that mattered, so I came at it from both ends. A probe replicating The other four. Query clearing verified live — with One new defect, pushed as c884506. Still open, low. Tests. Second opinion. codex at xhigh, twice. Its first pass reviewed the pre-d3a35fd tree — every line number predated your commit and it reported all five fixed items as still open — so I re-ran it pinned to the current file. That pass found the Unrelated and pre-existing, but worth someone's attention. The #7332 overlap still stands, unchanged since 18 August. That one is the maintainer's call, not yours. |
rememberedY was reset on panel open, filter changes and explicit positioning, but survived the peer set becoming a different tailnet: scroll deep into a 4000-machine account, switch away and back, and the list restores a position in a machine list the user has never seen. Reset it (and the peer cursor) when selectedAccountId changes, so an account switch starts at the top the way it did before the scroll fix. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Thanks for checking these by mechanism — the scroll-restore probe and the live cursor-hold test are exactly the verification this needed.
That leaves #7332 overlap as the one open item, which is the maintainer's call. |
`tailscale switch --list --json` publishes an empty selected id on any non-zero exit — including when `pollWatchdog` reaps it — while the user is still on the same tailnet, and the recovery poll then publishes the id back. Reading either edge as an account switch scrolled a hand-scrolled list to the top, which is the scroll loss this branch exists to prevent arriving through a different signal. Compare against the last account actually seen instead, so only a move between two real tailnets resets. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Re-reviewed at d6a8a18. The handler is live and it does what you meant it to — but it fires on more than an account switch, and I pushed a guard. The fix works. I gave the stub two 4000-machine tailnets this time, so a remembered offset from one is a perfectly valid offset in the other and a list that lands at the top did so because the code reset it, not because a clamp did. Scrolled The defect: It is not hypothetical, and it is worse on a big tailnet: anything that reaps an in-flight poll lands on exactly that non-zero exit path, and a slow Pushed 79618d8. It keeps the last account actually seen and resets only when the new id is non-empty and different, so Switching to a tailnet that is down renders correctly with c884506 in place — I checked because that commit made Tests. Second opinion. codex at xhigh, pinned to d6a8a18 with line anchors it had to quote back — it confirmed all six, so this pass was a review of the right tree. It reached the same empty-id defect. I had already reasoned to it and pointed its prompt at that code, and its independence is not currently guaranteed, so read that as agreement rather than a separate discovery; the one thing it added that I had not worked out is that a failed parse also empties Waiting on the maintainer now: the overlap with #7332 is still open and still their call. |
|
Good catch on the empty-id edges — the failed-poll path never crossed my mind as a "switch", and you're right it's the same scroll loss through a different door. 79618d8 kept as-is; comparing against the last account actually seen is the right place for it, since Service clearing the id on failure is honest about what it knows and the panel is where "did the user actually move?" belongs. Also ported it to my local build, where it's now running against the real 4k tailnet. Nothing further from my side — the branch is at 79618d8 with everything verified, and it's the maintainer's call on the #7332 overlap and sequencing with #7774. |
Since this branch was cut, quattro builds panel content on first open (omacom#15044), routes every string through I18n with catalogs (omacom#15326), restyled the copy menu for right-to-left layouts, and qualifies palette references for Qt 6.12. The branch's intent is ported onto that structure rather than the old one restored. The machine list, its search field and the shared copy menu now live inside the lazily built content, so root-level code reaches them through `panel.loadedContent` like the panel's other items, and every root caller tolerates them being null before the first open. The account-switch reset still records the last account seen while the panel has never opened, so the first open after a switch is not mistaken for one. The shared copy menu takes quattro's right-to-left placement, opening from whichever end the row's copy button sits at, and `Commons.Color`. The machine count, search placeholder, loading and no-match texts get English catalog entries, with the counts formatted for the language. Co-Authored-By: Claude Opus 5.5 <[email protected]>
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThis PR reduces the work needed to show large Tailscale networks.
No actionable issues were found. This review did not include runtime or visual verification.
|
|
Brought this up to current What the merge had to port, and why. The three textual conflicts were the small part. Since August
What ran. Everything ran on a disposable VM whose compositor was serving 6b5f1b3. I confirmed
The last row matters for Not checked. The right-to-left copy-menu placement was only read, not run under an RTL language. The copy menu on a row near the panel's bottom edge extends below the card. Reading Second opinion. Codex Medium and muse-spark-1.3-contributor (via pi, thinking high) reviewed 6b5f1b3 and found no defects. Between them they traced every root-level use of the lazily built content and its null guard, the first-open ordering against Overlap. #7332 also edits the machine list in Waiting on the maintainer. |
- The charger-swap monitor unit's omarchy-pkgs companion is open as omacom/omarchy-pkgs#1629 (companion of omacom/omarchy#15668); the 0002 entry no longer says it isn't opened, and the draft is gone. - Tailscale panel (0016): our omacom/omarchy#15671 is closed in favour of omacom/omarchy#7623 (c872d57cf). - Stranded lock (0024, 0027): #15912 is at ab447851e, which 0024 matches; the thread endorses 0027 (ddfdcf77) for it. - hid-asus Win-lock (0568): v1 fails checkpatch since 1e035297ffda removed the Assisted-by trailer from the kernel docs; a v2 goes to linux-input after v7.4-rc1. The recipes' NOTES.md and the omarchy-settings DELTA comment say the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The charger-swap monitor unit's omarchy-pkgs companion is open as omacom/omarchy-pkgs#1629 (companion of omacom/omarchy#15668); the 0002 entry no longer says it isn't opened, and the draft is gone. - Tailscale panel (0016): our omacom/omarchy#15671 is closed in favour of omacom/omarchy#7623 (c872d57cf). - Stranded lock (0024, 0027): #15912 is at ab447851e, which 0024 matches; the thread endorses 0027 (ddfdcf77) for it. - hid-asus Win-lock (0568): v1 fails checkpatch since 1e035297ffda removed the Assisted-by trailer from the kernel docs; a v2 goes to linux-input after v7.4-rc1. The recipes' NOTES.md and the omarchy-settings DELTA comment say the same. Co-authored-by: rdoupe <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
… Omarchy 4.5.0rc2 (#376) * omarchy 4.5.0rc2-1.101: rebase onto Omarchy 4.5.0rc2 Our patches are now on fork branch asus/v4-5-0-rc2. Most of the adaptations follow upstream's test cleanup: it dropped tests that only read source text (omacom/omarchy#16334), so our edits to them go (0003, 0017, 0026, general-0004), and it merged the stranded-lock test into hyprland-session-lock-test.sh (omacom/omarchy#16337), where 0024's and 0027's cases are ported. 0016 now sits on top of omacom/omarchy#7623, which rc2 ships: the IPN-bus watch replaces its light closed-panel poll, and opening the panel fetches every peer. general-0001's timer stub moves beside upstream's new plugin stub. No carried fix is in rc2, so nothing drops. Co-Authored-By: Claude Opus 5.5 <[email protected]> * omarchy-settings 4.5.0rc2-1.101: rebase onto Omarchy 4.5.0rc2 The same patches as omarchy, from fork branch asus/v4-5-0-rc2; upstream now installs Omarchy's timesyncd drop-in. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: rdoupe <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Resolve conflicts with the virtualized machine list (omacom#7623) and the panel translations (omacom#15326): publishPeers now writes the cached _peers that the visible peers list derives from, the offline switch sits beside the counted MACHINES header, and the new switch, empty-state and Offline strings are English catalog entries. The runtime fixture builds the lazily created panel content (omacom#15044), feeds statuses as full peer fetches, and qualifies its palette references (omacom#14553). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CFeF4GVPAdJb4fXF29e79S
Problem
On a corporate tailnet with ~3,900 machines, the tailscale widget makes the shell unusable.
tailscale status --jsonis ~4.6 MB there, and every 30-second poll reassignspeers, which rebuilds one eager row per peer — each row carrying its own copy-menuPopup— on every bar. Traced with the QML profiler, that is ~500k QML object creations per refresh. On my machine (3,933 peers, two monitors) it meant:Changes
Repeater+Columnbecomes a clippedListViewwithreuseItems; only the visible rows exist, and pooled rows are reused across refreshes./focuses it, Escape clears), match count in the section header. A 4,000-row list isn't navigable by scrolling alone.Popuppositioned at whichever row summoned it, instead of one instantiated per peer.peers/exitNodes/mullvadRegionswhen the parsed content actually changed, so an unchanged poll rebuilds nothing.tailscale status --json --peers=false(~3 KB); the full peer list is fetched when the panel opens or on explicit refresh.Keyboard navigation (j/k cursor, Enter → copy menu, taildrop send, panel tabbing) is preserved; the cursor and copy actions operate on the filtered list. Small tailnets look and behave exactly as before.
Numbers (3,933-peer tailnet, two bars)
Screenshot
Panel against a synthetic 4,000-machine tailnet (fake
tailscaleCLI used for the capture, so no real hostnames appear):🤖 Generated with Claude Code