Skip to content

fix(daemon): use Workstation GC for netclawd (#1294)#1295

Merged
Aaronontheweb merged 2 commits into
netclaw-dev:devfrom
Aaronontheweb:fix/1294-daemon-workstation-gc
Jun 2, 2026
Merged

fix(daemon): use Workstation GC for netclawd (#1294)#1295
Aaronontheweb merged 2 commits into
netclaw-dev:devfrom
Aaronontheweb:fix/1294-daemon-workstation-gc

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Summary

Switches netclawd from Server GC to Workstation GC (with background collection).

Netclaw.Daemon builds on Microsoft.NET.Sdk.Web, which defaults ServerGarbageCollection to true. There was no override, so the daemon shipped with Server GC. That's the wrong trade for this process:

  • netclawd is single-tenant and low-concurrency — one operator, a handful of sessions, a SignalR gateway and webhook listener.
  • We run it in memory-limited containers (1Gi). Server GC reserves larger segments, keeps one heap per core, collects Gen2/LOH less eagerly, and is slow to return memory to the OS — so peak RSS is higher and transient allocation spikes are more likely to trip the cgroup OOM killer.
  • Server GC's throughput win (saturating many cores under heavy allocation churn) doesn't apply to this workload.

This came out of investigating real OOM kills on a log-pulling daemon. The root allocation problem is tracked separately (#1293, unbounded shell_execute output buffering); Server GC is what turned that spike into a kill instead of a hiccup.

Change

<ServerGarbageCollection>false</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>

Verification

  • dotnet build -c Release clean (0 warnings, 0 errors).
  • Confirmed netclawd.runtimeconfig.json now emits System.GC.Server: false and System.GC.Concurrent: true.

Notes for review

Worth a sanity check that no high-throughput self-hosted deployment is leaning on Server GC. For the agent's actual concurrency profile, Workstation should be the better default. Easy to revert or make environment-conditional (DOTNET_gcServer) if needed.

Closes #1294.

netclawd builds on the Web SDK, which defaults ServerGarbageCollection to
true. The daemon is a single-tenant, low-concurrency process typically run
in a memory-limited container, where Server GC inflates peak RSS and is slow
to return memory to the OS — turning transient allocation spikes into cgroup
OOM kills. Switch to Workstation GC with background collection.

Verified System.GC.Server=false in the generated netclawd.runtimeconfig.json.
@Aaronontheweb Aaronontheweb added the performance Memory, CPU, and I/O optimization issues. label Jun 2, 2026
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) June 2, 2026 14:21
@Aaronontheweb Aaronontheweb merged commit 962de66 into netclaw-dev:dev Jun 2, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Memory, CPU, and I/O optimization issues.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

netclawd runs Server GC by default (Web SDK); Workstation GC suits the daemon's container footprint

1 participant