Repository navigation
fix(devserver): cap concurrent hot-reload workspaces, disable oldest without closing the socket - #24240
Conversation
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
Adds a process-wide cap on concurrent app hot-reload workspaces in the DevServer Host to prevent unbounded Roslyn workspace / EnC session memory growth across long-lived /rc connections.
Changes:
- Introduces
HotReloadWorkspaceRegistry+HotReloadWorkspaceOptionsto evict oldest hot-reload workspaces beyond a configured capacity. - Registers app-workspace slots once the workspace reaches
Ready, and disables hot reload (without closing the socket) on evicted connections. - Adds unit tests covering eviction order, idempotent registration, unregister behavior, and live capacity drops.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UI.RemoteControl.ServerCore/Uno.UI.RemoteControl.ServerCore.csproj | Adds Options package dependency used by the new registry/options types. |
| src/Uno.UI.RemoteControl.ServerCore/InProcess/InProcessDevServer.cs | Registers options + singleton registry in the in-process server DI setup. |
| src/Uno.UI.RemoteControl.ServerCore/HotReloadWorkspaceRegistry.cs | New registry/options + slot contract to cap concurrent hot-reload workspaces and evict oldest. |
| src/Uno.UI.RemoteControl.Server/Helpers/ServiceCollectionExtensions.cs | Registers options + singleton registry in the shared remote-control server DI setup. |
| src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.MetadataUpdate.cs | Registers the connection’s slot when the workspace becomes Ready. |
| src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs | Implements eviction handling by disabling hot reload without closing the socket. |
| src/Uno.UI.RemoteControl.Host/Program.cs | Binds HotReloadWorkspaceOptions from configuration at host startup. |
| src/Uno.UI.RemoteControl.DevServer.Tests/Given_HotReloadWorkspaceRegistry.cs | Adds tests for eviction, unregister, idempotency, and live capacity drop behavior. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24240/wasm-skia-net9/index.html |
…without closing the socket A reused/long-lived dev-server accumulates one Roslyn workspace + EnC session (~hundreds of MB) per connected app, with no bound: each app connection keeps its own workspace, and reconnect/restart loops stack them. See #24205 / #24151. Introduce HotReloadWorkspaceRegistry, a DI singleton configured through the Options pattern (HotReloadWorkspaceOptions, MaxConcurrentWorkspaces, default 5) bound from the 'HotReload' configuration section and read via IOptionsMonitor. Each app connection that initializes a hot-reload workspace registers a slot once it is Ready; IDE-driven connections (no workspace) never register, so only app workspaces are counted. When capacity is exceeded, the oldest slot(s) have hot reload disabled: their workspace / DebuggingSession is disposed to reclaim the memory, the end-of-life is reported to the app over the hot-reload status channel (SendUpdate + HotReloadEvent.Disabled), and the /rc connection is kept open so the client does not trigger an auto-reconnect storm. A configuration change that lowers the capacity is applied live via IOptionsMonitor.OnChange (the surplus oldest workspaces are evicted immediately); the registry disposes that subscription (IDisposable). Adds Given_HotReloadWorkspaceRegistry covering eviction (oldest-first, keeps Capacity slots), unregister, idempotent register, and live capacity-drop. Fixes #24205
e02e174 to
6f95b92
Compare
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs:513
- During workspace-cap eviction, the workspace
CancellationTokenSourceis canceled but not disposed. Since this runs on a reused dev-server and evictions can happen repeatedly, this can leak wait handles over time.
var workspace = _workspace;
_workspace = null;
workspace?.Ct.Cancel();
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24240/wasm-skia-net9/index.html |
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
|
@Mergifyio backport release/stable/6.7 |
✅ Backports have been createdDetails
|
…6.7/pr-24240 fix(devserver): cap concurrent hot-reload workspaces, disable oldest without closing the socket (backport #24240)
GitHub Issue: closes #24205
PR Type:
🐞 Bugfix
What changed? 🚀
A reused / long-lived dev-server accumulates one Roslyn workspace + EnC session (~hundreds of MB) per connected app, with no upper bound: each
/rcapp connection owns its own workspace, and reconnect / restart loops (or a stale half-open socket) stack them — measured at ~+500 MB per extra connection (see #24205 / #24151).This adds a process-wide cap on concurrent hot-reload workspaces:
HotReloadWorkspaceRegistry(inUno.UI.RemoteControl.ServerCore), a DI singleton configured through the Options pattern:HotReloadWorkspaceOptions.MaxConcurrentWorkspaces(default 5), bound at startup from theHotReloadconfiguration section and read viaIOptionsMonitor(e.g.HotReload:MaxConcurrentWorkspaces,UNO_DEVSERVER_HotReload__MaxConcurrentWorkspaces, or--HotReload:MaxConcurrentWorkspacesthrough the existing config pipeline).DebuggingSessionis disposed to reclaim the memory, and the end-of-life is reported to the app over the existing hot-reload status channel (HotReloadTracker.SendUpdate(serverError: …)+HotReloadEvent.Disabled)./rcconnection is kept open — only the HR processor's workspace is torn down — so the client does not trigger an auto-reconnect / retry storm. The file-update gate reportsFailed(terminal-but-not-closed), neverDisposed.IOptionsMonitor.OnChange(the surplus oldest workspaces are evicted immediately); the registry disposes that subscription (IDisposable).This is terminal for the evicted connection (its app is told hot reload ended and why); the app gets a fresh HR session on its next launch.
PR Checklist ✅
Given_HotReloadWorkspaceRegistry(eviction: oldest-first, keepsCapacityslots; unregister; idempotent register; live capacity-drop).