11 ms·
What .NET 10 GC changes mean for developers
See also: Preparing for the .NET 10 GC - https://news.ycombinator.com/item?id=45358527 https://news.ycombinator.com/item?id=45358527
- mrcsharp 1y agoOn the topic of DATAS, there was a discussion here recently: https://news.ycombinator.com/item?id=45358527 https://news.ycombinator.com/item?id=45358527
- dang 1y agoThanks! Macroexpanded: Preparing for the .NET 10 GC - https://news.ycombinator.com/item?id=45358527 https://news.ycombinator.com/item?id=45358527 - Sept 2025 (60 comments)
- dtech 1y agoInteresting, I mostly work in JVM, and am always impressed how much more advanced feature-wise the .NET runtime is. Won't this potentially cause stack overflows in programs that ran fine in older versions though?
- sbinder 1y agoI don't think the runtime is "much more advanced", the JVM has had most of these optimizations for years.
- grumpyprole 1y agoThe JVM famously boxes everything though, probably because it was originally designed to run a dynamic language. An array list of floats is an array list of pointers. This created an entire cottage industry of alternative collections libraries with concrete array list implementations.
- ysleepy 1y agoA float[] is packed and not a list of pointers in the jvm. An ArrayList<Float> is a list of pointers though.
- grumpyprole 1y agoArrays have a static fixed size though, making them far less useful in practice. Anything one builds with generics is boxed. Dotnet doesn't have this problem.
- pjmlp 1y agoCurrently you can get around this with Panama, even if the API is kind of verbose for the purpose. Eventually value classes might close the gap, finally available as EA.
- mrsmrtss 1y agoValhalla is over 10 years in the works already and there is still no clear date when or if at all it would be released. It's very difficult to change (or fix) such fundamental things so late in the game.
- pjmlp 1y agoBecause it is a huge engineering effort to add value types without breaking existing binary libraries. Doing a Python 3 would mean no one wanted going to adopt it. Yes it is long process. Some of the JEP in the last versions are the initial baby steps for integration.
- vips7L 1y agoThey're famously working on changing that. I think we're all hopeful that we'll start seeing the changes from Valhalla roll in post-25.
- dtech 1y agoAlmost none of this is in the JVM. Escape analysis is extremely limited on the standard JVM, and it's one of GraalVM's "enterprise" features. You have to pay for it.
- doikor 1y ago> one of GraalVM's "enterprise" features. You have to pay for it. Free for some (most?) use cases these days. Basically enterprise edition does not exist anymore as it became the "Oracle GraalVM" with a new license. https://www.graalvm.org/faq/ https://www.graalvm.org/faq/
- kimixa 1y agoOne limitation of the stack is that it needs to be contiguous virtual addresses, so it was often limited when devices just didn't have the virtual address space to "waste" on a large stack for every thread in a process. But 64 bits of virtual address space is large enough that you can keep the stacks far enough apart that even for pretty extreme numbers of threads you'll run out of physical memory before they start clashing. So you can always just allocate more physical pages to the stack as needed, similar to the heap. I don't know if the .net runtime actually does this, though.
- throw-qqqqq 1y ago> So you can always just allocate more physical pages to the stack as needed, similar to the heap. You set the (max) stack size once when you create the thread and you can’t increase the (max) size after that. Processes see a virtual address space that is handled by the OS, so you would have to involve the OS if you needed to add to the stack size dynamically.
- kimixa 1y agoAfter process start and it's initial state, the stack is just another virtual address and the just sp another register. It can be mapped, remapped, changed to point to whatever. With overcommit even the initial state may not be entirely backed by physical pages. Many userspace apps already do custom stack handling, it's how things like green threads work. And many non-native runtimes like .net already have custom handling for their managed stacks, as they often have different requirements and limitations to the "native" stack, and often incompatible formats and trying to isolate from possible bugs means there's less benefit to sharing the same stack with "native" code.
- neonsunset 1y ago[dead]
- samus 1y agoI am surprised that they didn't already do a lot of optimizations informed by escape analysis, even though they have had value types from the beginning. Hotspot is currently hampered by only having primitive and reference types, which Project Valhalla is going to rectify.
- adzm 1y ago> Won't this potentially cause stack overflows in programs that ran fine in older versions though? That's certainly a possibility, and one that's come up before even between .net framework things migrated to .net core. Though usually it's a sign that something is awry in the first place. Thankfully the default stack sizes can be overridden with config or environment variables.
- yread 1y agoI think that DATAS also has more knobs to tune it than the old GC. I plan to set the Throughput Cost Percentage (TCP) via System.GC.DTargetTCP to some low value so that is has little impact on latency. https://learn.microsoft.com/en-us/dotnet/core/runtime-config/garbage-collector https://learn.microsoft.com/en-us/dotnet/core/runtime-config...
- highwaylights 1y agoVery mixed feelings about this as there’s a strong case for the decisions made here but it also moves .NET further away from WASMGC, which makes using it in the client a complete non-starter for whole categories of web apps. It’s a missed opportunity and I can’t help but feel that if the .NET team had gotten more involved in the proposals early on then C# in the browser could have been much more viable.
- pjmlp 1y agoWebassembly taking off on the browser is wishful thinking. There are a couple unicorns like Figma and that is it. Performance is much better option with WebGPU compute, and not everyone hates JavaScript. Whereas on the server it is basically a bunch of companies trying to replicate application servers, been there done that.
- breve 1y ago> Webassembly taking off on the browser is wishful thinking. It has taken off in the browser. If you've ever used Google Sheets you've used WebAssembly.
- pjmlp 1y agoAnother niche use case.
- breve 1y agoGoogle Sheets is one of the most widely used applications on the planet. It's not niche. Amazon switched their Prime Video app from JavaScript to WebAssembly for double the performance. Is streaming video a niche use case?
- easton 1y agoI think they meant most people aren’t building a high performance spreadsheet, not most people aren’t using a high performance spreadsheet.
- cake-rusk 1y agoAre you now allowed to benchmark the .Net runtime / GC? Edit: Looks like you are allowed to benchmark the runtime now. I was able to locate an ancient EULA which forbade this (see section 3.4): https://download.microsoft.com/documents/useterms/visual%20studio%20.net%20professional_2003_english_be8aa149-b0fd-494d-a902-07fdb2007b90.pdf https://download.microsoft.com/documents/useterms/visual%20s... > You may not disclose the results of any benchmark test of the .NET Framework component of the Software to any third party without Microsoft’s prior written approval.
- Krutonium 1y ago...Were you not before?
- cake-rusk 1y agoIIRC the EULA forbids it. This is why you don't see .net v/s Java GC comparisons for example.
- rezonant 1y agoI can't find mention of anything resembling this. The .NET runtime is under the MIT license.
- jfyi 1y agohttps://download.microsoft.com/documents/useterms/visual%20studio%20.net%20professional_2003_english_be8aa149-b0fd-494d-a902-07fdb2007b90.pdf https://download.microsoft.com/documents/useterms/visual%20s... It's because you aren't looking at 20 year old EULA's >3.4 Benchmark Testing. The Software may contain the Microsoft .NET Framework. You may not disclose the results of any benchmark test of the .NET Framework component of the Software to any third party without Microsoft’s prior written approval. This person is not likely familiar with the history of the .net framework and .net core because they decided a long time ago they were never going to use it.
- elmigranto 1y agoUse managed language, it will handle memory stuff for you, you don’t have to care. But also read these 400 articles to understand our GC. If you are lucky, we will let you change 3 settings.
- phito 1y agoIt works just fine out of the box. The articles/manuals are just if you want to really understand how it works and get the most out of it. What's the issue with that?
- samus 1y agoYou need these settings when you drive your application hard into circumstances where manual memory allocation arguably starts making sense again. Like humongous heaps, lots of big, unwieldy objects, or tight latency (or tail latency) requirements. But unless you're using things like Rust or Swift, the price of memory management is the need to investigate segmentation faults. I'd prefer to spend developer time on feature development and benchmarking instead.
- pjmlp 1y agoDr. Dobbs and The C/C++ Users Journal archives are full of articles and ads for special memory allocators, because the ones on the standard library for C or C++ also don't work in many cases, they are only good enough as general purpose allocation.
- bob1029 1y agoYou can provide your own GC implementation if you really wanted to: https://learn.microsoft.com/en-us/dotnet/core/runtime-config/garbage-collector#standalone-gc https://learn.microsoft.com/en-us/dotnet/core/runtime-config... https://github.com/dotnet/runtime/blob/main/src/coreclr/gc/gcinterface.h https://github.com/dotnet/runtime/blob/main/src/coreclr/gc/g...
- JaggerJo 1y agoInteresting!
- 1y ago
- 1a527dd5 1y agoDATAS has been great for us. Literally no effort, upgrade the app to net8 and flip it on. Huge reduction in memory. TieredCompilation on the other hand caused a bunch of esoteric errors.
- neonsunset 1y agoFWIW Tiered Compilation has been enabled on by default since .NET Core 3.1. If the code tries to use refection to mutate static readonly fields and fails, it's the fault of that code.
- adzm 1y agoA hobby audio and text analysis application I've written, with no specific concern for low level performance other than algorithmically, runs 4x as fast in .net10 vs .net8. Pretty much every optimization discussed here applies to that app. Great work, kudos to the dotnet team. C# is, imo, the best cross platform GC language. I really can't think of anything that comes close in terms of performance, features, ecosystem, developer experience.
- grumpyprole 1y ago> C# is, imo, the best cross platform GC language. I really can't think of anything that comes close How about F#? Isn't F# mostly C# with better ergonomics?
- denismenace 1y agoHe means the runtime ".NET CLR". They have the same runtime.
- Xss3 1y agoLmao, functional programming is far from ergonomic
- grumpyprole 1y agoF# is hardly modern functional programming. It's more like a better python with types. And that's much more ergonomic than C#.
- ZenoArrow 1y agoPython and F# are not very similar. A better comparison is OCaml. F# and OCaml are similar. They're both ML-style functional languages.
- grumpyprole 1y agoI'd much rather code F# than Python, it's more principled, at least at the small scale. But F# is in many ways closer to modern mainstream languages than a modern pure functional language. There's nothing scary about it. You can write F# mostly like Python if you want, i.e. pervasive mutation and side effects, if that's your thing.
- dgllghr 1y agoI am considering dotnet Maui for a project. On the one hand, I am worried about committing to the Microsoft ecosystem where projects like Maui have been killed in the past and Microsoft has a lot of control. Also XML… On the other hand, I’ve been seeing so many impressive technical things about dotnet itself. Has anyone here used Maui and wants to comment on their experience?
- Dusseldorf 1y agoSpeaking as an experienced desktop .NET Dev, we've avoided it due to years of instability and no real confidence it'll get fully adopted. We've stuck with WPF, which is certainly a bit warty, but ultimately fine. If starting fresh at this point I'd give a real look at Avalonia, seems like they've got their head on their shoulders and are in it for the long haul.
- eterm 1y agoIf you're windows based, I'd unironically consider winforms, it's been re-added to dotnet in windows, and is one of the easiest and best ways to make simple GUI applications. Sadly it's not cross-platform, which is a benefit of MAUI.
- maxlb 1y agoI've been a C# developer my entire career and spent a few years building apps with Xamarin/Uno. At my current company, we evaluated MAUI and Flutter for our mobile app rewrite (1M+ monthly active users). We first built a proof of concept with 15 basic tasks to implement in both MAUI and Flutter. Things like authentication, navigation, API calls, localization, lists, map, etc. In MAUI, everything felt heavier than it should've been. Tooling issues, overkill patterns, outdated docs, and a lot of small frustrations that added up. In Flutter, we got the same features done much faster and everything just worked. The whole experience was just nicer. The documentation, the community, the developer experience... everything is better. I love C#, that's what we use for our backend, but for mobile developement Flutter was the clear winner. We launched the new app a year ago and couldn't be happier with our decision.
- 999900000999 1y agoI wonder if this makes .net competitive for high frequency trading...
- bob1029 1y agoIt's been competitive for a long time now. https://medium.com/@ocoanet/improving-net-disruptor-performance-part-3-introducing-the-valuedisruptor-5b467730bbe https://medium.com/@ocoanet/improving-net-disruptor-performa...
- klysm 1y agoWhy would you ever pick a language like this for HFT? It seems like a nonstarter for me but I guess Java is out there in use
- clanky 1y agoThere are plenty of domains where the competition is not one of pure latency (where FPGAs and custom hardware have even taken over from C++). In these domains managed languages can be sufficient to get to "fast enough" and the faster iteration speed and other comforts they provide can give an edge over native languages.
- pjmlp 1y ago"Why we chose Java for our High-Frequency Trading application" https://medium.com/@jadsarmo/why-we-chose-java-for-our-high-frequency-trading-application-600f7c04da94 https://medium.com/@jadsarmo/why-we-chose-java-for-our-high-...
- CharlieDigital 1y agoBenchmark Games[0] shows C# just behind C/C++ and Rust across a variety of benchmark types. C# has good facilities for dipping into unmanaged code and utilizing hardware intrinsics so you'd have to tap into that and bypass managed code in many cases to achieve higher performance. [0] https://benchmarksgame-team.pages.debian.net/benchmarksgame/download/fastest-elapsed-gm.svg https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- honkostani 1y agoI always found that Jit and GC are a marriage destined to come together, but never found one another entirely. Jit marks the hotloop in code- and thus can tell the GC in detail what a generation really is and how long a generation lifetime really lasts. It can reveal secret cull conditions for long generational objects. If that side-branch is hit in the hot-loop, all longterm objects of that generation, are going to get culled, in a single stroke… so bundle them and keep them bundled. And now they started using it, to at least detect objects that do not escape lambdas. So its all stack, no more GC involved at all. Its almost at the static allocation thing we do for games. If the model proofs that every hotloop 5 objects are allocated and life until a external event occurs- static allocation and its done. Great start. But you could do so much more than that with this. If you write a custom JIT whose goal is not just to detect and bytecompile hotloops, but to build a complete multi-lifetime model of object generation.
- whizzter 1y agoAny interpreter could theoretically do those "marking" things, also JIT's do far more than just "bytecompile" hot loops, _all_ cooperative modern GC's are enabled by JIT semantics for things like read and/or write barriers (this helps a GC keep track of objects that keep getting "touched" whilst the GC can work in parallel). Outside of the mentioned, things like detecting finegrained lifetimes is very very hard and the mentioned escape analysis is an optimization that needs to be capped to avoid the halting problem. (1) A fairly deep covererage of GC behaviours can found in Bacon's "Unified Theory of Garbage Collection" where the author theoretically connect previous works on tracing collectors and reference-counting systems and show that the optimized variations often existing in a design-space between them. (2) 1: https://en.wikipedia.org/wiki/Halting_problem https://en.wikipedia.org/wiki/Halting_problem 2: https://web.eecs.umich.edu/~weimerw/2008-415/reading/bacon-garbage.pdf https://web.eecs.umich.edu/~weimerw/2008-415/reading/bacon-g...
- honkostani 1y ago[dead]
- andyjohnson0 1y agoComprehensive and (I thought) interesting article in perf improvements in .net 10: Performance Improvements in .NET 10 https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-10/ https://devblogs.microsoft.com/dotnet/performance-improvemen...
- OtherShrezzing 1y agoThis is a great article, as soon as you’re beyond the introductory 5 paragraphs on the minutiae of the opening song of Disney’s Frozen.
- deleted 1y ago[deleted]
- torginus 1y agoDo these updates mean that the JIT can finally optimize LINQ away into simple loops?
- mrcsharp 1y agoLINQ doesn't need the JIT for that. I don't even think it is the JIT's responsibility to be aware of a specific library and optimize for it. LINQ does a lot of work behind the scene to optimize for speed and reduce allocations. An example can be found here [1]. These optimizations are mostly about reducing the various LINQ patterns into simple for loops. [1] https://github.com/dotnet/runtime/blob/main/src/libraries/System.Linq/src/System/Linq/Where.SpeedOpt.cs#L398 https://github.com/dotnet/runtime/blob/main/src/libraries/Sy...
- torginus 1y agoWithout JIT support, using Linq involves at least allocating an IEnumerator object on the heap, and a closure object, and a delegate to it (if said delegate captures local vars). Each call to `Select` or `Where` is also a virtual call. This is hugely expensive compared to just a for loop. With this update it seems like the JIT can do escape analysis to stack-allocate the closure object, and the delegate as well (it could devirtualize calls even before that). It seems like it has everything to optimize away the whole LINQ overhead, though I'm not sure what happens in practice. It'd be neat since that was a major argument against actually using LINQ in perf-sensitive code.
- CharlieDigital 1y agoThere's also ZLinq: https://github.com/Cysharp/ZLinq https://github.com/Cysharp/ZLinq
- andyayers 1y agoSometimes, yes. Linq contains a goodly number of hand-crafted special-case enumerators for common collections, or collections with certain interfaces, or span projections that are really nice optimizations but can complicate things for the JIT. Some details here if you're curious: https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/jit/DeabstractionAndConditionalEscapeAnalysis.md https://github.com/dotnet/runtime/blob/main/docs/design/core...
- mtmmtm 1y agoAll of this is just a clone of features of java. They even copied the name from java: "escape analysis". https://en.wikipedia.org/wiki/Escape_analysis https://en.wikipedia.org/wiki/Escape_analysis
- andyayers 1y ago.NET JIT developer here. What else would we call it? It is what it is. I believe there are some differences between what .NET does and what mainstream Java does. For instance, objects can be stack allocated even if they can't be turned into collections of scalars. This allows the JIT to stack allocate small known-sized arrays.
- selinkocalar 1y agoGarbage collection improvements are always welcome. We've had some .NET services where GC pauses were causing noticeable latency spikes under load. I think the regional GC approach is potentially promising if it’s for applications with large heaps. I’ll bet most web apps probably won't notice much difference though.