Skip to content

perf: harden runtime state and trim hot paths - #128

Merged
harryisfish merged 12 commits into
mainfrom
perf/runtime-robustness
Nov 16, 2026
Merged

harryisfish merged 12 commits into
mainfrom
perf/runtime-robustness

Conversation

@harryisfish

@harryisfish harryisfish commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Goal

Improve runtime robustness and rendering performance based on a read-only review of the controller, the GPUI window, the System Extension, and the browser extension popup.

Scope

  • Runtime: report system-proxy restore and set failures, confirm the core's ports are free after disconnect, recover from a poisoned operation lock, keep the previous core log on restart, reopen the app log after rotation by another process.
  • GPUI: keep logging and repeated member resolution out of the render path, build via choices on demand, compute connection filters once per poll, drop unused per-tick strategy clones, surface external strategy parse errors.
  • System Extension: async logging, one idle timer per relay, per-datagram UDP errors no longer end the session, fast fallback when the loopback SOCKS backend is waiting, cheaper rule matching, a UDP session idle timeout, a HostBridge data race.
  • Browser extension popup: WCAG AA contrast in both themes, a labeled rule input, a 24px delete target.

Verification

  • CI build passes on the final head.
  • Rust library tests and Network Extension shared tests pass; browser extension scripts pass syntax checks.
  • Independent review found no open issues on the final head.
  • Not verified here: System Extension behavior on a signed install.

Owner: @harryisfish

Status: verified, ready for review.

Dark mode now overrides secondary and status text, the primary button and
destructive text use darker tokens, the rule input has a label, and the
delete control has a 24px target.
Restore checks every networksetup call and keeps the snapshot on failure,
surfacing the reason after disconnect. Reclaim fails when a leftover core
survives SIGKILL instead of claiming its ports are free. A poisoned
operation lock no longer blocks every later operation, a failed system
proxy sync stays visible in health, the previous core log survives a
restart, and the app log reopens after another process rotates it.
Group membership resolution no longer writes a warning per missing pin on
every frame; compile reports missing pins instead. Membership, via
choices, delay lookup, and the GLOBAL list use hashed lookups, via menus
build their choices only when opened, and health polling stops cloning
and reloading the strategy it never read. A deleted or unreadable
strategy.json is reported instead of being retried or replaced with
defaults.
Keep one open file descriptor on a private serial queue, reopen it when
the Rust side rotates the log, and keep flock around each append.
Relay distribution metrics become debug-only and are skipped unless
developer logging is on; the ring copies sources under its lock and
aggregates outside it.
Data paths now only stamp activity; a single dispatch timer re-arms for
the remaining interval instead of scheduling a work item per chunk.
A Mihomo SOCKS connection that enters waiting fails at once and takes
the existing fallback, since the loopback listener cannot recover.
Oversized, over-budget, unconvertible, unroutable, and failed-destination
datagrams are dropped and counted instead of closing the whole flow.
Rejected destinations are kept as records; a socket with only rejected
destinations still ends immediately. Idle conversations share one session
timer, and a session with no destination for the idle interval finishes
so its admission slot returns.
Normalize the hostname, derive suffix candidates, and resolve the
executable name once per flow instead of per rule; skip empty suffix
indexes and store wildcard pattern characters at construction.
…lies

The UDP admission-failure path now closes the claimed flow even when its
activity record is gone. The host activity bridge locks its result box
so a reply that arrives after the timeout is discarded safely.
@harryisfish
harryisfish force-pushed the perf/runtime-robustness branch from 62be7b3 to 68731b7 Compare November 16, 2026 18:19
Popup and background scripts had no preflight scope, so changes under
browser-extension/ could not be accepted. A syntax check is the only
build-free signal they have.
Record a system proxy sync failure after the health reset so it stays
visible, including after automatic recovery. When a leftover core
survives, finish resetting runtime flags and the restore note before
returning the error. Skip network services that no longer exist when
restoring the system proxy. Stop a UDP session drop from overwriting the
parent activity once its own conversation has reported.
A successful recovery resets health, which dropped the sync error it had
just recorded, and a recovery note hid it. Keep the error across resets
and append it to any note. Treat services macOS has disabled as still
present when restoring, so their proxy settings are not abandoned.
Keeping the sync error across health resets also carried it into the next
connect attempt and past a successful restore. Clear it when a connect
starts and when disconnect restores the system proxy.
@harryisfish
harryisfish marked this pull request as ready for review November 16, 2026 18:37
@harryisfish
harryisfish merged commit 8055578 into main Nov 16, 2026
1 check passed
@harryisfish
harryisfish deleted the perf/runtime-robustness branch November 16, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant