256 points · by benaadams · 8y ago · 118 comments
The most important since at least framework 4.0 maybe even 3.0.
We are getting:
- Span<T>/Memory<T> : A 0-copy, unified way of accessing Managed or Unmanaged memory.
- Channel<T> : High performance thread-safe queues (like go channels)
- Pipelines : an async, 0-copy version of Stream
- In-box support for Array/Buffer pooling (finally!) (MemoryPool, ArrayPool)
- Better primitives for pointer manipulation and memory marshaling. (MemoryMarshal)
- New primitives for high performance parsers and formatters (System.Buffers.Binary and System.Buffers.Text)
- Improved support for SSE/NEON via Vector<T>
- Microsoft.Windows.Compatibility : Windows specific APIs on .NET Core (Registry, EventLog, NamedPipes...)
- Tiered Compilation
- Faster tooling
- Wider Platform support
If you write code on .NET, you should [Edit] evaluate this release with to see if it fits your business needs [/Edit]
Doubly so if you care about runtime performance.
That really depends what classes you use. There are still a lot of classes that haven't been implemented in .Net Core and many of them supposedly won't be implemented. Others were re-implemented and renamed and might not match features. You'll want to move to .Net Core eventually, but not every .Net release is going to be easy to move. Moving from .Net Framework to .Net Core is like moving from .Net Framework to mono. It's mostly similar, but it's still wholly different and not intended to be a 100% drop in replacement.
The Microsoft.Windows.Compatibility namespace isn't new at all. At least that's what the Windows Compatibility Pack for .Net Core [0] used at the end of 2017. It looks like it might just finally be out of the preview stages.
[0]: https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcin...
If you require the new features maybe, but if you are writing enterprise code, you shouldn't rush into things.
> Doubly so if you care about runtime performance.
Everyone cares about runtime performance, but if your software isn't experiencing performance issues, there is no need to rush into things. Or at the very least, reach out to your clients to get a feel about their schedules and expectations.
#1 rule: if it ain't broke, don't fix it.
I dont get these claims to not upgrade unless you're also just as worried about changing a line of code and having it all break too? Make the changes, test the changes, and deploy carefully, just as you would for anything else.
I've seen legacy code get created by people postponing platform updates for so long that the upgrade pathways stop being supported, that's one way.
I've also seen legacy code get created by people adopting the platform of the future super-early, and then being left high and dry when the rest of the world decided that platform wasn't actually the future after all, leaving them as the sole maintainers of the entire platform as well as their dependent code.
If your code currently works on standard .net, there's no reason to be in a massive hurry to move to .net core. There's not necessarily any reason to delay, either. It all depends on your business requirements and the investment required. If it's easy for you to move to .net core then by all means do it. If it's gonna be a massive project, let the smaller groups go first.
I care about performance, but:
Still have customers on .NET 4.0.
.NET Core 2.1 doesn't do EF6, Forms or WPF, need to wait for 3.0 for that.
Not all third party libraries are already on Core.
Given all that, Core 2.1 is full of goodies that I will surely play around with.
...But reading between the lines, you probably still have clients on XP (.NET 4.0). That's gotta sting. We made a fuss about TLS1.2 support being required and forced them to upgrade to Win7/.NET 4.5.2 at least.
I have gotten gotten a smallish winforms app to work with the new .csproj format. But it's painful. WPF is probably a nightmare.
As an aside if you make it to .NET 4.5+ and get async/await. It works great with winforms and presumably WPF!
Nope, we cannot make it to .NET 4.5+ due to some third party libraries, which is a bummer, because we are stuck with BackgroundWorker as TPL had some bugs with Forms on 4.0, which were only fixed on 4.5.
It is only one project thought, the other issue are the IT upgrade policies regarding developer images.
Note that you don't have to install netcore on machines, you can create self-contained releases[1].
> EF6, Forms or WPF
Depending on your architecture you may be able to upgrade to netcore piecewise (i.e., microservices over "dumb" protocols like HTTP or gRPC). We are currently turning our monolith into microservices; porting to netcore where possible (using an anti-corruption layer where not). We've only just started but are already reaping benefits.
[1]: https://docs.microsoft.com/en-us/dotnet/core/deploying/#self...
For native GUI applications it is nothing than a waste of resources.
Three tier architectures with modular designs across several assemblies are a much better solution, no need to go after what is cool.
The EF6, Forms and WPF support is the major goal of .NET Core 3.0, so why should I ask our customers to waste money with microservices and application rewrites?
But it is pretty simple to use. It is in nuget package "System.Threading.Channels".
You basically call Channel.CreateBounded<T>(int) to create a channel that will buffer a limited number of T objects.
A Channel has a ChannelReader and ChannelWriter which are two ends of the same channel. The reader is the output side, the writer is the input side.
Each side exposes methods to synchronously try to Read or Write or asynchronously Read or Write (respectively).
It supports "Completion" meaning that the Writer can signal the Reader(s) that it is done writing forever. For example imagine you had a channel that was for Log Messages. A bunch of readers might be listening, but then the App shuts down. The writer can call "Complete()" on the channel and the Readers will get wake up and get a message that there is no more messages and flush themselves and shut down.
As a note you will need to run your own processing thread to await messages from the channel. Unlike Dataflow which will span it's own taks to handle messages.
I will write up an example Gist and reply to this thread in a little bit.
Other notes: - The API is very similar to Dataflow since Stephen Toub wrote them both. - It is extremely fast. I have seen > 1.25M messages per second in my benchmarks. - It is mostly allocation free due to using the new ValueTask<T> which is a struct
Futher Reading: https://www.nuget.org/packages/System.Threading.Channels/ https://apisof.net/catalog/System.Threading.Channels
https://gist.github.com/AlgorithmsAreCool/b0960ce8a3400305e4...
This sounds very similar to the channels (Chan [1]) in Haskell, which I really loved playing around with.
[1] http://hackage.haskell.org/package/base-4.11.1.0/docs/Contro...
https://msdn.microsoft.com/en-us/library/dd267265(v=vs.110)....
Also, we need a GUI, of some kind.
Blazor (.NET webassembly) + Electron is an interesting option though for the future.
https://blogs.msdn.microsoft.com/dotnet/2018/05/07/net-core-...
Would be .NET Core 3 you'd be waiting for then:
https://blogs.msdn.microsoft.com/dotnet/2018/05/07/net-core-...
I wish they worked on their release notes with samples for all the smaller features like formatters, pooling and channels. Too much of it is buried in github issues.
Channel<T> uses ValueTask<T> which is kinda painful in F# for now.
Be sure to check your environment variables are set properly. Also, be sure to check that they haven't added additional opt-out settings, or remove the ability to opt-out all together. If you haven't opted-out on purpose, be sure you're still OK with what they're collecting.
From my perspective, it seems like something that'll be used in the guts of ASP.NET and the rest of the base class library that will benefit the performance of my code, but I'd never really use it directly.
The real selling point is that Span is much more flexible than an Array. Both Managed and Unmanged memory can work with it. If you load a big string and need to get each line from it, you can slice into the middle of the string safely and get a ReadOnlySpan<char> that supports most 'string' operations without allocating any memory.
Or imagine you need to process some huge file, typically you would read it chunk by chunk copying the data from the Stream into some byte[]. But with Span you could open a Memory Mapped File and work on segments of the file without copying into temp buffers.
You gain a lot by avoiding memory copies and by allocating fewer objects (less work for the GC). For some workloads then can be a huge speedup.
Also it means you can now pass readonly arrays (the elements) to things using ReadOnlySpan<T>; so don't have to do defensive copies
Tons of reasons to use them besides performance. We use them for those reasons and if there is a performance boon, great bonus!
- Deployments: https://www.microsoft.com/net/customers
- Monthly engaged developers is >500k for NET Core.
- >50% of developers are on Windows.
We know that .NET Core is generally liked by Microsoft developers (with good reason), but I have no idea what corporate adoption is like, and would love to see indicators that people are actually migrating production systems. The existance of Core makes Framework that bit more annoying to deal with, and it would be nice to see that things are moving.
Corporate adoption is very good afaik. For .NET developers, .NET Core is a lot of fresh air and also a long overdue defence against Node. They want to continue to work with C# :)
It's not a simple subset of .NET Framework, there are distinct differences and cross-platform is just one ability. It's also smaller, faster, and allows for self-contained deployments that can run with other apps using different framework versions on the same machine. Also very simple to use in containers.
https://docs.microsoft.com/en-us/dotnet/standard/choosing-co...
.NET core is a fully supported option on Google's AppEngine via flexible instances, so I think it's stable enough for production deployments.
Now with .NET Core 3.0 roadmap and MSIX containers, their are slowly merging Win32 and UWP worlds.
I've found it's a little tricky to get used to calling Slice() all the time. But it opens up so many doors for allocation reduction and perf improvement.
Also, it is so nice to not have to pass (array, offset, length) around everywhere
"Much easier to manage platform dependencies in project files and with self-contained application publishing."
Anybody know anything about this? I frequently deal with applications that have platform specific components, and it's a real pain. Sometimes the platform specific code is a platform-specific native dll that gets called from the same P/Invoke wrapper, sometimes it's two different managed implementations of the same interface, sometimes it's both. It'd be great if this sort of thing got easier to do.
I updated the wording to: "Much easier to manage .NET Core and ASP.NET Core versions in project files and with self-contained application publishing."
The thing that you are talking about still needs to be improved. Sadly, that didn't happen in this release.
Given the immense engineering hours went into CoreCLR, why aren't more languages built on top of .NET runtime?
Language alternatives show up by need (not given here) or specialization (niche you never heard of).
But if you are using VS you will need to update to 15.7 to take advantage of some of the features/
https://www.microsoft.com/net/learn/get-started/macos
On mac they appear to be recommending visual studio code with the c# extension. I'd agree that that makes for a decent experience.
Alternatively:
Rider: https://www.jetbrains.com/rider/ VS for Mac: https://www.visualstudio.com/vs/mac/
VSCode and Rider are the two standouts. I love VSCode on windows and Linux, but I have heard nothing but good things about Rider.
https://docs.microsoft.com/en-us/dotnet/standard/choosing-co...
It is actually the opposite of your statement. Mono is massively adopting .NET Core source code but without loosing their own benefits (portability and factoring).
The license allows it to be forked.
Would be nice to read more about it especially how to measure performance benefits
But now that it exists we can expect regular improvements with every point release.