10 ms·
Performance Improvements in .NET Core
- alkonaut 9y agoI hope most or all these will find their way into the full framework. It's a bit odd that this is so rarely mentioned. I still haven't quite grasped the relation between core and the full framework when it comes to fixes like this being merged into the full framework.
- ksubedi 9y agoAs .net core is a full rewrite, all these optimizations are .net core specific, so porting them isn't going to be a easy thing.
- yawgmoth 9y agoHopefully these optimizations are for a particular version of .NET Standard and will see themselves in both .NET Framework and .NET Core.
- jacobparker 9y agoSkimming, but it doesn't look like these optimizations are relevant to .NET standard (which is a formal specification of a set of APIs - not a particular implementation.)
- runfaster2000 9y agoCorrect. Performance improvements are out of the scope of the standard. Much like how the HTML spec doesn't tell Google and Microsoft how fast their browsers need to work.
- deleted 9y ago[deleted]
- paavohtl 9y ago.NET Core is not a rewrite in any way. It's the same runtime with the same GC and JIT, same language compilers and mostly the same standard library. It has just been stripped down by removing deprecated features (such as code sandboxing / partial trust) and made support non-Windows platforms. You might have confused it with ASP.NET Core, the web development framework, which is a full rewrite.
- runfaster2000 9y agoFrom the post: “We expect that many of these improvements will be brought to the .NET Framework over the next few releases, too” We still need to ensure that all the changes are behavioral compatible. Other than that, we are intending on improving the .NET Framework as well with these same performance investments.
- matthewwarren 9y ago> I still haven't quite grasped the relation between core and the full framework when it comes to fixes like this being merged into the full framework. From what I can tell, from following the CoreCLR repo (https://github.com/dotnet/coreclr https://github.com/dotnet/coreclr), it's changed over time. In the beginning the sources of the 2 were more closely tied, changes were (automatically?) copied over. Now it seems like it's more ad-hoc, done as and when they decide it's needed. See the mentions of 'TFS Mirror' in this thread for a bit more info https://github.com/dotnet/coreclr/issues/972#issuecomment-254681149 https://github.com/dotnet/coreclr/issues/972#issuecomment-25...
- matthewwarren 9y agoIf you take a look as these issues, it's clear that they're happy to make the source code very different, i.e. hard/impossible for changes to be automatically ported across. Just look at how much .NET Framework (Desktop) code they removed from CoreCLR earlier this year! - https://github.com/dotnet/coreclr/issues/8857 https://github.com/dotnet/coreclr/issues/8857 - https://github.com/dotnet/coreclr/issues/8763 https://github.com/dotnet/coreclr/issues/8763 - https://github.com/dotnet/coreclr/issues/4651 https://github.com/dotnet/coreclr/issues/4651 - https://github.com/dotnet/coreclr/pull/9058 https://github.com/dotnet/coreclr/pull/9058
- avtar 9y ago> Just look at how much .NET Framework (Desktop) code they removed from CoreCLR earlier this year! Perhaps I'm missing something but wouldn't removing Windows specific code from a now cross platform runtime be the obvious thing to do?
- ellism 9y agoFWIW (I work on the .NET Team and I wrote the mirror we use to keep TFS and GitHub in sync). When we started the project we maintained a mirror which kept our GitHub repository and internal TFS branch in sync. After a while, we decided that trying to maintain this was more harm that it was worth (the internal TFS branch used a completely different build system and there were other interactions between code which had been open source and code that hadn't that meant our internal branch was on the floor every few days), in addition it meant that we were carrying around a bunch of effectively dead code in the source tree. We still do mirror some code (mainly the JIT) into TFS to make it easier to share code with the Desktop in an automated fashion. However, for the rest of the code (e.g. the VM and BCL), if there are improvements we want to bring back, an engineer will just port them manually.
- Analemma_ 9y ago> This is another great example of a developer caring a lot about a particular area of .NET and helping to make it better for their own needs and for everyone else that might be using it. This is a great, succinct, non-ideological explanation for why open-source projects where anyone can contribute tend to be better. For a given component/function, there might be only a single person in the entire world who needs that optimized badly enough to actually do it themselves, but once they do, everyone benefits. A closed-source team has to prioritize their development efforts, which means niche improvements will probably never make it in. Multiply this by a thousand different niches, and the product is going to be slower.
- bhauer 9y ago> but once they do, everyone benefits This is such a good point. We (TechEmpower) had this in mind when we created our framework benchmarks project a few years back. Performance improvements in platforms and frameworks have the potential of very broad impact. With our project, we wanted to provide some inspiration for doing that kind of performance tuning. We had found ourselves in many conversations about how many real-world CRUD web applications take multiple seconds to render a page with a form. We realized that if, just as an example, the JSON serializer or template engine were substantially faster, many real-world applications that use those components would see notable improvements to their user experience.
- yodon 9y agoI was expecting maybe 10% improvements, but many of these are 30x perf improvements on common collection operations
- yread 9y agoThe List. Add change is small but its hand optimized assembly, quite impressive.
- hacker_9 9y agoWorth noting it's not hand written assembly, but instead writing C# code in a very specific way in order to encourage the compiler to implement more aggressive optimizations (inlining, bounds check removals, etc).
- sproketboy 9y agoMaybe at some point .net will be faster than Java.
- drej 9y agoWhenever I look at drastic improvements in performance, I remember that a while ago I managed to speed up a custom parser at work, by about 30x. When I emailed my colleagues, I just said "You may consider this to be work of a genius. Or you may think I was stupid when writing the original implementation. I'll let you pick the narrative that you fancy." Interpretations are fun when there's a baseline :-)
- jdmichal 9y agoReminds me of when I replaced a read-write lock around generating a new object instance with an atomic reference instead. I personally put that one into the latter of your two cases... But the performance improvement certainly looked heroic!
- old-gregg 9y agoEvery time I try to get a quick feel of .NET on Linux, I allocate an hour to it and that hour is always spent wandering around various guides on microsoft.com and never getting anything done. There are terms like .NET Core, .NET Platform, .NET Framework, .NET SDK all mixed up on nearly every page, multiple versions of "Getting started" and "Quick start" guides, massive navigation menus and options on every page so you never know if you're looking at the latest and greatest or it's some kind of abandoned dark corner of a web property, as it often happens with corporate sites. Yo! If you want .NET to be a massive hit on non-Windows platforms, move it off Microsoft.com to a small site, have a single version of "getting started" (and only one "guide"). Don't ever mention things that exist and don't work on Linux. Like this: https://golang.org/doc/ https://golang.org/doc/ Also, have a simple downloadable .tar.gz which expands into /bin + /lib + /examples. I loved C# back in my Windows days and I moved to Linux to escape Microsoft complexities and over-reliance on complex IDEs and tools, scattered like shrapnel all over my c:/ I will not run apt-get against your repo without knowing ahead of time what I'm getting and where will it all go, so let me play with the tarball first. [EDIT] formatting
- H1Supreme 9y agoYeah, the Microsoft docs are all always a pain to navigate. A lot of seemingly duplicate content. Not that Apple's docs were any better for many years (Swift docs are much better). In contrast to those two, I've found Android's pretty good in the 3 years I've been referencing them.
- runfaster2000 9y agoPoint taken. We have some improvements to make on this front.
- old-gregg 9y agoRooting for you guys. Lots of bad-ass tech has been locked up on Windows for years, can't wait to see it everywhere.
- wslh 9y agoI know you are in the .NET team but we have critical issues with Microsoft (we are MSDN subscribers) that are not addressed. The most critical issue is the impossibility to pass automated tests and sign a network device driver because of a Windows 10 bug! If you can help routing this inside the organization would be great. More info about the issue here: https://social.msdn.microsoft.com/Forums/SharePoint/en-US/b1fd3d1a-44a2-4138-9370-cd1409293697/sparta-miniport-interfaces-failed-to-start-in-windows-10?forum=whck&forum=whck https://social.msdn.microsoft.com/Forums/SharePoint/en-US/b1...
- polskibus 9y agoI wish they used benchmark.net for measuring performance. It can give much more trustworthy measurements for such microoptomizations.
- mellinoe 9y agoThis is mentioned in the post, in case you missed it: > Further, normally such testing is best done with a tool like BenchmarkDotNet; I’ve not done so for this post simply to make it easy for you to copy-and-paste the samples out into a console app and try them. We love BenchmarkDotNet and use it (and other perf tools) quite a lot internally.
- SpikeDad 9y agoAlways interesting timing by technology companies. Here's a post to developers by Microsoft the day AFTER Apple's State of the Union presentation to developers. Microsoft touting performance improvements the day after Apple amps up performance on pretty much every aspect of the Apple developers infrastructure (Xcode, Swift, APIs, processor and GPU utilization, etc). Must be a coincidence...
- matthewwarren 9y ago> Must be a coincidence... I have no way of knowing for sure, but I doubt a blog post that long, published on an official M/S blog (i.e. probably requiring sign-off) could be written that quickly!
- runfaster2000 9y agoI was personally involved in the publishing of this post. The timing of this post and the Apple event didn't even register with us as interesting. We're an engineering team and have zero interest in cross-company tactics like that. Now, if there is an LLVM release you want to tell me about ... ;)
- manigandham 9y agoWhat difference does it make when .NET Core is cross platform anyway?
- st0le 9y ago> For example, SortedSet<T>‘s ctor was originally written in a relatively simple way that didn’t scale well due to (I assume accidentally) employing an O(N^2) algorithm for handling duplicates. Now that's a gross oversight.
- Sammi 9y agoDude. Be fair. You left out the part where he says: > In other cases, operations have been made faster by changing the algorithmic complexity of an operation. It’s often best when writing software to first write a simple implementation, one that’s easily maintained and easily proven correct. However, such implementations often don’t exhibit the best possible performance, and it’s not until a specific scenario comes along that drives a need to improve performance does that happen. For example, SortedSet<T>‘s ctor was originally written in a relatively simple way that didn’t scale well due to (I assume accidentally) employing an O(N^2) algorithm for handling duplicates. You'll never get anything done if you want to get it perfect the first time round. Or as they say, first make it work, then make it right, then make it fast.
- bitmapbrother 9y agoWhat's up with the memory consumption of C# .Net Core? It looks like it has dethroned Java as the memory bloat champion. http://benchmarksgame.alioth.debian.org/u64q/csharp.html http://benchmarksgame.alioth.debian.org/u64q/csharp.html
- ygra 9y agoMay come down mostly to Java being able to use 32-bit references on a 64-bit JVM in certain cases. Many of those programs are very heavy on references. C# can gain a bit in some cases due to value types, but it doesn't always help enough.
- matthewwarren 9y agoI don't know what's taking up the memory in those benchmarks. However in CoreCLR there are multiple efforts to reduce memory consumption, mostly driven by the ports to other architectures (e.g. ARM, ARM32), see https://github.com/dotnet/coreclr/search?q=memory+consumption&type=Issues&utf8=%E2%9C%93 https://github.com/dotnet/coreclr/search?q=memory+consumptio...
- runfaster2000 9y agoWe haven't spent much time with those benchmarks. We looked at a couple of them and believe that there are better ways to write them in C# and get better results. That's not FUD but our findings. This is a great community activity. Clearly, the community is more than capable of performance enhancements, based on the improvements they have made in the product. If people start improving the C# benchmarks, please file an issue on dotnet/core to get feedback and some cred. We may do another blog post on that if there is some gravity around the activity.
- voltagex_ 9y agoAre any of those discussions around better way to write the benchmarks public? From a very quick look, something like http://benchmarksgame.alioth.debian.org/u64q/program.php?test=revcomp&lang=csharpcore&id=2 http://benchmarksgame.alioth.debian.org/u64q/program.php?tes... looks like a direct port from a C program, rather than idiomatic C#.
- olegkikin 9y agofor (int i = 0; i < 10_000_000; i++) { s_result = s.Min; } Shouldn't your compiler completely fold this? There are no side effects, it's single-threaded. This should take microseconds, not 86 milliseconds.
- int_19h 9y agoIt's pretty tricky for the runtime to figure out that there are no side-effects, and that s.Min is not going to change, if the implementation behind it actually walks some nodes. Among other things, it would require it to prove that none of the walked nodes ever mutate anywhere else (don't forget that this includes backdoors like reflection).
- piaste 9y agoAre there any notable languages that flat-out forbid reflection, or treat it as undefined behaviour?
- primeblue 9y agoA very understated company. Microsoft keeps getting better. Open sourcing so many things. C# and Visual Studio is a breath of fresh air compared to the bloated, aging and vexing obfuscation called Java (work in both). Since 1991 Microsoft Research keeps making contributions.
- arwhatever 9y agoYay performance improvements to IEnumerable<T>/LINQ, to further take away people's excuses for not writing code in a more declarative style.
- arwhatever 9y agoYay performance improvements to IEnumerable<T>/LINQ, to further take away people's excuses for not writing code in a more declarative style.
- martinald 9y agoThe real problem for me is compatibility of NuGets with .NET core. I have so many which are just not compatible and many which have a slightly different Core variant with weird gotchas. As such I've stuck with .NET 4.5 for now. On the positive side Mono seems to have got a lot better and I have a bunch of stuff running on Linux with surprisingly few problems "out of the box".
- pier25 9y agoIs there something like Heroku but for dotnet core apps? I'd like to play a bit with it but it should be as easy as pushing to a repo to deploy and run.
- flukus 9y agoWhy do you need to push to a repo to deploy/run? If you want to play just create a project and run it locally.
- pier25 9y agoI'd like to avoid any installation hassles. What would be the easiest way to run on macOS?
- philipri 9y agoYou can easily deploy them to GCP's AppEngine Flexible with a simple dockerfile. It's pretty close to the 'git push heroku master' experience. https://cloudplatform.googleblog.com/2016/10/how-to-use-Docker-to-run-ASP.NET-Core-apps-on-Google-App-Engine.html https://cloudplatform.googleblog.com/2016/10/how-to-use-Dock...
- staticelf 9y agoI would say Azure. Push deploy is very easy to setup.
- koyote 9y agoThis is great and a very detailed report as well! Although if I understood this correctly, these performance improvements will only take effect if you compile using .Net Core 2.0 and run using .Net Core 2.0 runtime? I did not realize .Net Core had diverged this much from .Net Framework.
- josteink 9y ago> I did not realize .Net Core had diverged this much from .Net Framework. Yeah me too. On the flip side I consider it a healthy sign for the project as a whole and especially as an open-source undertaking.
- cspsolutions 9y agoOwning and managing software business we develop using multiple technologies Mobile objective c, swift, Android java, xamarin.net, phone gap Web asp.net Mvc , php, java Etc... Using Asp.net Mvc requires using 3rd party ui libraries and Depends on size of team and experience in .net, usually we assign.net developers with at least 4 years experience in .net and front-end currently mvvm js libraries If you starter in .net you have learning curve but this is reducing as technologies improve