runtime icon indicating copy to clipboard operation
runtime copied to clipboard

DATAS costs ~25% on .NET 11 RC1 where it was free on .NET 10 (allocation-heavy parallel workload)

Open keithadler opened this issue 2 months ago • 6 comments

Summary

On a workload that allocates small objects continuously across many threads, enabling DATAS costs nothing on .NET 10 and about 25% on .NET 11 RC1. .NET 11 RC1 also has it on by default, so the cost arrives on upgrade with no change to the project.

Measurements

Both builds identical apart from the target framework, neither pinning System.GC.DynamicAdaptationMode. Interleaved runs on one machine, best of three, identical input every time, twelve worker threads. Server GC, concurrent off.

.NET 10 .NET 11 RC1
Runtime default 9.91 s 13.16 s
DOTNET_GCDynamicAdaptationMode=1 9.74 s 13.07 s
DOTNET_GCDynamicAdaptationMode=0 9.88 s 10.50 s

Reading the rows:

  • .NET 10: DATAS is free. On and off are within noise of each other and of the default.
  • .NET 11 RC1: DATAS costs 24.5%. 13.07 s against 10.50 s.
  • .NET 11 RC1 defaults to DATAS on. The default row matches the forced-on row, not off.
  • With DATAS off, the two runtimes are close: 9.88 s and 10.50 s.

One thing I could not determine: whether .NET 10's default is on or off. Since DATAS makes no measurable difference there, timing cannot distinguish the two. The regression is in what DATAS costs, and that is measurable on both.

The penalty scales with thread count, which is what pointed at the GC rather than codegen:

.NET 10 .NET 11 RC1 Delta
1 worker thread 28.50 s 31.13 s +9.2%
12 worker threads 10.19 s 13.20 s +29.5%
GC-inclusive CPU, summed across workers 61.88 s 88.51 s +43%

Workload

An independent implementation of the Lean 4 theorem prover's kernel, re-checking formal mathematics. It allocates expression tree nodes continuously, holds a large live set that stays reachable for the whole run (hash-consed terms and memo caches), and runs one worker per core over independent items. A batch job that wants a heap to grow once and stay large.

Open source, MIT OR Apache-2.0: https://github.com/keithadler/tenet

Repro

Needs elan for a Lean toolchain, which supplies the input data, and both SDKs.

git clone https://github.com/keithadler/tenet && cd tenet
elan toolchain install leanprover/lean4:v4.34.0
LIB=~/.elan/toolchains/leanprover--lean4---v4.34.0/lib/lean

# remove the pin this project ships, so the runtime default is what runs
sed -i '' '/DynamicAdaptationMode/d' src/Tenet.Cli/Tenet.Cli.csproj
dotnet build -c Release

sed -i '' 's|net10.0|net11.0|' Directory.Build.props
python3 -c "import json;d=json.load(open('global.json'));d['sdk']['rollForward']='latestMajor';json.dump(d,open('global.json','w'))"
dotnet build -c Release

for t in net10.0 net11.0; do
  for m in unset 1 0; do
    [ $m = unset ] && unset DOTNET_GCDynamicAdaptationMode || export DOTNET_GCDynamicAdaptationMode=$m
    /usr/bin/time src/Tenet.Cli/bin/Release/$t/tenet check $LIB/Init.olean --all --quiet
  done
done

tenet check --timing reports the GC-inclusive CPU figures directly.

Environment

macOS 26.6.2, arm64, 12 cores, 16 GB. SDKs 10.0.400 and 11.0.100-rc.1.26425.128. ServerGarbageCollection=true, ConcurrentGarbageCollection=false, verified identical in both generated runtimeconfig.json files.

Note

Not arguing DATAS is the wrong default in general. It is right for services that should return memory, and this workload is the opposite case. The report is that its cost on this shape of work changed from nothing to a quarter of runtime between an LTS and the next STS, which a project's own diff gives no sign of.

keithadler avatar Sep 16 '26 05:09 keithadler

Tagging subscribers to this area: @karelz, @dotnet/ncl See info in area-owners.md if you want to be subscribed.

dotnet-policy-service avatar Sep 16 '26 05:09 dotnet-policy-service

Tagging subscribers to this area: @anicka-net, @dotnet/gc See info in area-owners.md if you want to be subscribed.

dotnet-policy-service avatar Sep 16 '26 05:09 dotnet-policy-service

Thanks for the detailed measurements. Region-based GC was not supported in .NET 10 on macOS, and it is a prerequisite for DATAS. Thus, the System.GC.DynamicAdaptationMode setting existed, but setting it to either 0 or 1 had no effect.

.NET 11 enabled region-based GC on macOS in #125416, which also activated DATAS there for the first time. Therefore, what you observe is a comparison of inactive DATAS on .NET 10 with active DATAS on .NET 11.

And as you've mentioned, DATAS is probably not the best match for this type of workflow.

kkokosa avatar Sep 16 '26 11:09 kkokosa

DATAS is probably not the best match for this type of workflow

Just throwing in When DATAS might not be applicable to your scenario in case @keithadler didn't know this blog post.

gfoidl avatar Sep 16 '26 12:09 gfoidl

I tried it with Satori GC:

Server GC (no DATAS) Server GC (DATAS) Satori GC (Interactive) Satori GC (LowLatency)
10.212s 12.775s 11.268s 10.754s

hez2010 avatar Sep 16 '26 15:09 hez2010

Thanks @kkokosa, that explains it completely: on .NET 10/macOS DATAS was never active, so this is inactive vs. active DATAS rather than a regression. Thanks also @gfoidl for the blog link and @hez2010 for the Satori numbers. Closing, since it's working as designed. Always happy to help if more measurements would be useful.

keithadler avatar Sep 29 '26 21:09 keithadler