Repository navigation
internal/ui: rebuild the sidebar once per peer update, not once per page - #357
Open
horststaley wants to merge 1 commit into
Open
horststaley wants to merge 1 commit into
horststaley wants to merge 1 commit into
Conversation
Author
Owner
|
Sorry, I've been a bit tied up with some other things, but I'll try to get to this as soon as I can. |
Author
|
Thanks, and no worries. The exit node selection failure isn't from this PR: the |
AdwViewSwitcherSidebar rebuilds all of its rows whenever the stack's pages change, and MainWindow adds and removes pages one at a time, so opening the window with n peers took O(n²) row constructions. Detach the sidebar while an update adds, removes, or reorders pages. Fixes DeedleFake#102. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DeedleFake
force-pushed
the
sidebar-hold
branch
from
November 18, 2026 02:19
66cc73a to
82b0963
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #102.
AdwViewSwitcherSidebarconnects the stack'sitems-changedandsections-changedsignals torepopulate_sidebar(), which removes and recreates every row.MainWindowadds and removes stack pages one at a time, so with n peers:restack()removes and re-adds all of them because the first order comes from map iteration. That's about 3n full sidebar rebuilds, or O(n²) row constructions.This adds
holdSidebar, which unsets the sidebar's stack whileupdatePeers,updatePages, andapplyLayoutchange the stack's pages and sets it again afterwards, so the sidebar is rebuilt once per update. Holds nest. The sidebar is only detached when an update actually adds, removes, or reorders pages, so polls that change nothing don't touch it.Measured with a 178-peer tailnet in the GNOME 51 Flatpak runtime with software rendering. Main-thread CPU time per window open from the tray icon:
On v0.21.0,
MainWindow.Updateon first open went from 4.9 s to 0.25–0.3 s, andrestack()from 3.1 s to 25 ms. With the window open, toggling offline peers went from 2.4–2.9 s of CPU to 0.2–0.4 s. Most of what remains on open is GTK's first layout and paint.TestPeerUpdatesDontRebuildSidebarruns 200 peers throughupdatePeersand counts stack changes made while the sidebar is attached. Without this change it counts 601 for the first update, 402 when one peer goes offline, and 101 when half the peers leave, and takes 10 s. With it, it counts 0 and takes 0.3 s.Tested inside the GNOME 51 runtime under Xephyr:
go test -racepasses for all ten packages with tests.go vetandgo fix -diffare clean, andgo tool golangci-lint run --disable=errcheckreports 0 issues.🤖 Generated with Claude Code