perf: further reduce RSS for .NET (AOT) and Java (Native) - #5
Open
davideme wants to merge 3 commits into
Open
Conversation
Target: bring both implementations under 16 MB RSS (previously 17.1 MB and 17.9 MB respectively). Stays at flag/config level — no API swap. Java Native (memory.yml, ci.yml): - Lower heap: MaxHeapSize 16m → 8m, MinHeapSize 1m → 512k - Add MaxNewSize=2m to bound young generation under serial GC - Explicitly disable monitoring (--enable-monitoring=) - Drop deadlock watchdog thread (-H:DeadlockWatchdogInterval=0) .NET AOT (dotnet.csproj): - More trimming knobs: DebuggerSupport, StackTraceSupport, UseSystemResourceKeys, MetadataUpdaterSupport, EnableUnsafeBinaryFormatterSerialization, EnableUnsafeUTF7Encoding, IlcGenerateStackTraceData, IlcDisableReflection .NET runtime config: - Disable concurrent GC to drop background GC thread - Lower HeapHardLimit 20 MB → 12 MB - Return decommitted VM to OS (RetainVM=false) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
GraalVM 25.0.2 rejects an empty value for --enable-monitoring; the flag is an opt-in list (heapdump/jfr/jvmstat/...) with no "explicit none" form, since none is already the default. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…cbc06 # Conflicts: # .github/workflows/memory.yml
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.
Summary
Aim: bring .NET (AOT) and Java (Native) RSS under 16 MB. Current baseline from the
Memoryworkflow:This PR stays at the flag/config level — no HTTP API swap. If either implementation is still >16 MB after CI runs, a Phase 2 swap to
System.Net.HttpListener/ rawServerSocketis the planned fallback.Changes
Java Native (
.github/workflows/memory.yml,.github/workflows/ci.yml)MaxHeapSize 16m → 8m,MinHeapSize 1m → 512k, newMaxNewSize=2m. With--gc=serial, the GC sizes its committed regions against the max — lowering the cap is the single biggest expected win.--enable-monitoring=— explicit empty value to assert nothing (JFR, jvmstat, heap-dump, etc.) is enabled.-H:DeadlockWatchdogInterval=0— drops the watchdog thread..NET AOT (
dotnet/dotnet.csproj)Eight new trimming/feature-switch properties:
DebuggerSupport=false,MetadataUpdaterSupport=false— drop debugger and hot-reload metadata.StackTraceSupport=false+IlcGenerateStackTraceData=false— strip stack-trace string tables.UseSystemResourceKeys=true— replace localized exception messages with their resource keys.EnableUnsafeBinaryFormatterSerialization=false,EnableUnsafeUTF7Encoding=false— drop unused encoders.IlcDisableReflection=true— most aggressive;WebApplication.CreateSlimBuilder()is the slim path so this should be safe, but it's the easiest to revert in isolation if the publish breaks..NET runtime config (
dotnet/runtimeconfig.template.json)System.GC.Concurrent: true → false— drops the background GC thread (each thread reserves ~1 MB of stack visible in RSS); this is the biggest expected .NET win.System.GC.HeapHardLimit: 20 MB → 12 MB.System.GC.RetainVM: false— return decommitted segments to the OS sooner.Test plan
CIworkflow'sBuild native imagestep still succeeds (no broken flags).CIworkflow'sVerify HTTP 200step still passes (server starts and responds).Memoryworkflow report shows.NET (AOT)< 16384 KB.Memoryworkflow report showsJava (Native)< 16384 KB.MaxHeapSizeto4m; for .NET try removingIlcDisableReflectionfirst (if publish failed) or lowerHeapHardLimitto 10 MB.🤖 Generated with Claude Code