Skip to content

perf(build): SettingsRuntime reference + Settings pages as a workspace pane (#12737) - #13862

Merged
teamleaderleo merged 1 commit into
mainfrom
feat-nightly-build-speed
Sep 23, 2026
Merged

teamleaderleo merged 1 commit into
mainfrom
feat-nightly-build-speed

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Nightly Release compile of the cmux module drops from 935 s to 487 s per architecture. The nightly build step should go from about 20 min to about 12.5 min.

Cause. SettingsRuntime was a struct that embedded the whole SettingCatalog (about 24 KB of key declarations). Every @LiveSetting holds @Environment(\.settingsRuntime), so each view with a live setting stored the catalog inline. ContentView has five of them. Its fields are resilient SwiftUI wrappers, so IRGen expands a field-by-field destroy wherever a ContentView is copied or destroyed. Each expansion moved five 24 KB catalogs through registers: a 103k-instruction function with a 50 KB stack frame. There were 58 closure-context destructors of 413 KB each, plus 1.2 MB value witnesses, which made 32 MB of machine code per architecture in ContentView.o. LLVM's greedy register allocator took about 490 s on that file. With WMO, LLVM codegen runs on one thread for each file, so this single file set the length of the whole module's LLVM stage.

Fix. SettingsRuntime is now a final class. All of its members are immutable lets (actors, a @MainActor log, an existential and the catalog), so reference semantics do not change behavior. Each environment slot is now one pointer. cmuxApp, UpdateTitlebarAccessory, CanvasHostedPanelContentView and SettingsWindowScene, which store the runtime by value, shrink the same way.

Measured on warp-macos-26-arm64-12x, the nightly build runner class, with cold caches. The runs used temporary experiment workflows on branches that were not merged.

before after
ContentView.swift compile, per-file arm64 496 s 45.5 s
ContentView.o 45 MB 12.9 MB
cmux WMO frontend, each arch (universal) 935 s 487 s
of which LLVM pipeline 490 s 66 s
cold universal xcodebuild wall 1456 s 1069 s

Runs: before 35800014258 (profile) and 35806087265 (object symbol sizes). After: 35807874614.

The remaining WMO cost is SIL optimization at 280 s. It runs on one thread per architecture, and only splitting the module or dropping whole-module mode reduces it.

swift test in Packages/macOS/CmuxSettingsUI passes (177 tests).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Turns SettingsRuntime into an immutable reference type so views no longer store the full settings catalog inline. This halves the nightly cmux compile time per architecture (935 s to 487 s) and reduces ContentView's object file from 45 MB to 12.9 MB.

All existing members were already immutable, so semantics are unchanged and swift test passes.

Written for commit 0c2608a. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Refactor
    • Updated the settings runtime representation without changing its public API or initialization behavior.

Also includes #12737 (author lawrencecchen), merged here on request. It gives each Settings category its own page, adds Feature Flags search, and opens Settings as a workspace (Bonsplit) pane, with the window as a fallback. Conflicts with current main were resolved as follows:

  • .computers section: kept in the new per-page switch.
  • AutomationSection: main's managed socket-policy state is kept. The socket password draft moves to pageDrafts, as in 12737.
  • Localizable.xcstrings: merged per key with scripts/merge-xcstrings.py. No key had changes on both sides.
  • Cloud tree: main's pinned, source and devices parameters are kept, and 12737's includeEmptyLocalWorkspaces option is added to them. Row selection keeps main's isSelectable rule. The empty state uses includeLocalMachine: true to match the outline.

… the settings catalog

Every @LiveSetting holds @Environment(\.settingsRuntime). SettingsRuntime was a
struct embedding the whole SettingCatalog (~24 KB), so each view with a live
setting stored the catalog inline. Release codegen for ContentView then spent
~490s in LLVM register allocation on 103k-instruction value witnesses and 58
closure-context destructors (~413 KB each), 32 MB of machine code per arch.
The runtime's members are all immutable, so a final class keeps semantics and
shrinks each environment slot to one pointer.
@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: manaflow-ai/cmux/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: af30991f-ed32-432f-8616-7ed5e537fdbb

📥 Commits

Reviewing files that changed from the base of the PR and between 40e63ce and 0c2608a.

📒 Files selected for processing (1)
  • Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Environment/SettingsRuntime.swift

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

SettingsRuntime changes from a struct to a final class. Its public API, stored properties, initializer, and @unchecked Sendable conformance remain unchanged.

Changes

SettingsRuntime

Layer / File(s) Summary
Adopt reference semantics
Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Environment/SettingsRuntime.swift
SettingsRuntime is now a final class. Its documentation describes the type as an immutable reference handle and explains the reference semantics for the embedded SettingCatalog.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 0c260

The runtime representation changes to reduce copying overhead, with no actionable merge risk identified in the reviewed change.

🚥 Pre-merge checks | ✅ 25
✅ Passed checks (25 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change and its primary performance impact: converting SettingsRuntime to a reference type to reduce Swift compile time.
Description check ✅ Passed The description provides a detailed summary, rationale, measured performance results, and test results. It does not include the template checklist or review-trigger block, but the core required inform…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Cmux Cloud Persistent Session And Early Input ✅ Passed The pull request changes only SettingsRuntime.swift, switching an immutable settings bundle from struct to final class and updating its documentation. The authoritative diff contains no Cloud te…
Cmux Swift Actor Isolation ✅ Passed No actor-isolation failure was introduced. The diff only changes SettingsRuntime from a struct to a final class and documents its immutable reference design. Its stored properties remain let; th…
Cmux Swift Blocking Runtime ✅ Passed PASS: The PR changes only SettingsRuntime.swift, converting a struct to a final class and updating documentation. The diff introduces no semaphores, blocking waits, sleeps, delayed dispatch, pol…
Cmux Browser Automation Off-Main ✅ Passed The pull request changes only SettingsRuntime.swift, changing its storage from struct to final class and updating documentation. The diff contains no browser.* commands, WebKit waits, socket-w…
Cmux Expensive Synchronous Load ✅ Passed PASS. The authoritative diff changes only SettingsRuntime from a struct to a final class and updates documentation. It adds no agent-history loader, file read, JSON/JSONL parsing, directory scan, sy…
Cmux Cache Substitution Correctness ✅ Passed The PR changes only SettingsRuntime from a struct to a final class and updates its documentation. The diff contains no replacement of a fresh authoritative read with a cache, and no changes to persi…
Cmux No Hacky Sleeps ✅ Passed PASS. The authoritative diff changes only SettingsRuntime.swift, a Swift file, from a struct to a final class. It introduces no fixed sleeps, delayed dispatch, timers, polling, or wall-clock waits. …
Cmux Algorithmic Complexity ✅ Passed The PR changes only SettingsRuntime from a struct to a final class and updates documentation. It adds no collection scans, sorting, filtering, joins, batch rescans, or slower algorithms. The chang…
Cmux Swift Concurrency ✅ Passed The PR changes only SettingsRuntime.swift. The functional change is struct to final class, with documentation updates. The initializer, stored properties, and existing @MainActor annotation re…
Cmux Swift @Concurrent ✅ Passed PASS: The PR changes only SettingsRuntime from struct to final class and updates documentation. The changed file has no async, nonisolated, or @concurrent function changes, and its existin…
Cmux Swift Package Boundaries ✅ Passed The diff changes only Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Environment/SettingsRuntime.swift, which is already inside the CmuxSettingsUI SwiftPM target. The change only converts th…
Cmux Swiftpm Lockfiles ✅ Passed PASS. The authoritative pull-request diff changes only Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Environment/SettingsRuntime.swift. It does not change a package manifest, `Package.resolve…
Cmux Swift Logging ✅ Passed The PR changes only the SettingsRuntime type from struct to final class and updates documentation. It adds or materially changes no print, debugPrint, dump, NSLog, file/stdout logging, `…
Cmux User-Facing Error Privacy ✅ Passed PASS. The PR changes only SettingsRuntime.swift: it changes a runtime container from struct to final class and adds developer-facing performance documentation. It does not add or modify user-fac…
Cmux Full Internationalization ✅ Passed PASS: The PR changes only SettingsRuntime.swift. The diff changes a Swift type from struct to final class and adds developer-facing documentation about compile performance. It introduces no user…
Cmux Swiftui State Layout ✅ Passed PASS: The PR changes only SettingsRuntime.swift. The diff changes SettingsRuntime from a struct to a final class and updates documentation. It adds no ObservableObject, @Published, `@State…
Cmux Architecture Rethink ✅ Passed The PR changes only SettingsRuntime from an immutable struct to an immutable final class and keeps its public members and initializer unchanged. The diff introduces no sleeps, delayed dispatch, …
Cmux Swift Auxiliary Window Close Shortcuts ✅ Passed PASS: The authoritative PR diff changes only SettingsRuntime.swift. It changes a public struct to a final class and updates documentation. It adds or materially changes no NSWindow, NSPanel,…
Cmux Source Artifacts ✅ Passed The PR changes only Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Environment/SettingsRuntime.swift. The diff is a hand-written Swift source change that converts SettingsRuntime from a stru…
Cmux No Test Or Debug Seam In Production Source ✅ Passed The PR changes only Packages/macOS/CmuxSettingsUI/Sources/CmuxSettingsUI/Environment/SettingsRuntime.swift under production Sources. The diff changes SettingsRuntime from struct to `final clas…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@teamleaderleo

Copy link
Copy Markdown
Collaborator

Independent review of 0c2608a: immutable stored fields and existing actor/service references preserve the runtime dependency behavior; initialization remains MainActor-isolated, with no mutable value or Equatable contract removed. A second independent agent reached the same conclusion. Exact-head native Swift package and compile admission checks pass, all required checks are green, and CodeRabbit reported no actionable findings. Verified the cited universal profiling run completed successfully. Landing the measured compile reduction; the full production nightly improvement still needs observation after merge.

BasaltUnwind g1 🗝️

@teamleaderleo
teamleaderleo merged commit b432d7f into main Sep 23, 2026
53 of 56 checks passed
@teamleaderleo

teamleaderleo commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

this is green

we review a bit then let's get stuff merged asap
e: yeah

@lawrencecchen lawrencecchen changed the title perf(build): make SettingsRuntime a reference (halves nightly Swift compile) perf(build): SettingsRuntime reference + Settings pages as a workspace pane (#12737) Sep 23, 2026
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.

2 participants