It's out! #dotnet
Performance Improvements in .NET 11 - .NET Blog 🚀
devblogs.microsoft.com/dotne…
EgorBo retweeted
The .NET 10 performance blog post has landed
A monster of a read again from @stephentoub !
devblogs.microsoft.com/dotne…
EgorBo retweeted
It's been a year since I started my blog, so I rerun the benchmark on .NET9 RC2 (on the same machine). And it's indeed faster! Today I've got
Producer: 961K msg/s (+10%)
Consumer: 939K msg/s (+12%)
#fsharp #dotnet @apache_pulsar
xitter.cf/Lanayx/status/17162686…
EgorBo retweeted
It's that time again!
Performance Improvements in .NET 9 by @stephentoub
devblogs.microsoft.com/dotne…
EgorBo retweeted
Validating gigabytes of Unicode strings per second… in C#?
We have been working on a fast library to validate and transcode Unicode and other formats such as base64 in C++: simdutf. We wondered: could we achieve the same good results in C#?
Microsoft’s .NET framework has made great strides in leveraging advanced instructions. For instance, if your processor supports AVX-512, you can instantiate 512-bit registers right in C#! The standard .NET runtime library effectively utilizes these features, demonstrating that they practice what they preach.
Most strings on the Internet are Unicode strings stored in UTF-8. When you ingest such strings (from disk or from the network), you need to validate them. To test the waters, we set our eyes on UTF-8 validation. With John Keiser, I helped designed a fast UTF-8 validation algorithm designed for modern-day CPUs. We call the algorithm ‘lookup’. It may require less than one instruction per byte to validate even challenging input. The lookup validation algorithm is part of Oracle Graal, Google Fuchsia, the Node.js and Bun JavaScript runtimes and so forth.
The .NET library has its own fast UTF-8 validation function: Utf8Utility.GetPointerToFirstInvalidByte. It is highly optimized. As the name implies, it finds the location of the first byte where an error might occur. It also computes some parameters from which you can tell how the input could be transcoded. The function is an internal function, but we can expose it by copying and pasting it.
Could we beat the .NET runtime, at least some of the time? It seems that we can!
Maybe you want to know what our code looks like? Here is a simplified example where we load 64 bytes, check whether they are ASCII.
Of course, the whole algorithm is more complicated, but not that much more… It is maybe 30 lines of code. We implement various versions of the algorithm, one for ARM processors, one for older x64 processors, and so forth.
For benchmarking, we use valid strings. The first one we check is twitter.json, a JSON file that is mostly ASCII with some non-trivial Unicode content within strings. We also use various synthetic strings representative of various languages.
On an Intel Ice Lake system, our validation function is up to 13 times faster than the standard library. On twitter.json, we are 2.4 times faster.
On an Apple M2 system, our validation function is 1.5 to four times faster than the standard library.
Observe how the standard library provides a function that is already quite fast: it can run at gigabytes per second. We are several times faster, but evidently, C# makes it possible to write highly optimized functions.
You can run your own benchmarks by grabbing our code from GitHub.
It is a pleasure doing this performance-oriented work in C#. It is definitively one of my favorite programming languages right now.
cc @tannergooding @EgorBo
EgorBo retweeted
Just published an article digging deep into how arrays of doubles are aligned in #dotnet. With juicy bits about the allocation context, fake objects, and C# code that you definitely shouldn't deploy in production.
minidump.net/memory-alignmen…
EgorBo retweeted
How it started How it's going
EgorBo retweeted
Improving the performance of XxHash3 for ARM with this PR github.com/dotnet/runtime/pu…
See! That's a direct benefit from getting this handy dev kit! 😇
Just received this puppy, second fastest ARM64 at home browser.geekbench.com/user/4… below the M1 pro as expected, but for a dev kit, that's pretty good! It will help to optimize stuffs for ARM64 with VS and .NET 7! 😎
EgorBo retweeted
1/N One of my favorite optimizations in the upcoming .NET 7 Native AOT is static data preinitialization. This program prints a circle to the screen. Would you believe me if I said there is no code to compute the circle bytes in the NativeAOT'd executable file of this program?👇🧵
![class Program
{
static readonly byte[] s_bytes = ComputeCircleBytes();
static byte[] ComputeCircleBytes()
{
const int Width = 16;
byte[] bytes = new byte[Width * Width];
for (int i = 0; i < bytes.Length; i++)
{
int x = (i % Width) - (Width / 2);
int y = (i / Width) - (Width / 2);
if (x * x + y * y < (Width / 2) * (Width / 2))
bytes[i] = (byte)'*';
else if ((i % Width) == 0)
bytes[i] = (byte)'\n';
else
bytes[i] = (byte)' ';
}
return bytes;
}
static void Main()
{
System.Console.WriteLine(System.Text.Encoding.ASCII.GetString(s_bytes));
}
}](https://pbs.twimg.com/media/FcMz5XdaMAEm5ck.jpg?name=small&format=webp)
ALT class Program { static readonly byte[] s_bytes = ComputeCircleBytes(); static byte[] ComputeCircleBytes() { const int Width = 16; byte[] bytes = new byte[Width * Width]; for (int i = 0; i < bytes.Length; i++) { int x = (i % Width) - (Width / 2); int y = (i / Width) - (Width / 2); if (x * x + y * y < (Width / 2) * (Width / 2)) bytes[i] = (byte)'*'; else if ((i % Width) == 0) bytes[i] = (byte)'\n'; else bytes[i] = (byte)' '; } return bytes; } static void Main() { System.Console.WriteLine(System.Text.Encoding.ASCII.GetString(s_bytes)); } }
EgorBo retweeted
We are working on verifying assembly output for the JIT using LLVM's FileCheck, JitDisasm, and few other custom things.
I feel pretty good about it.
EgorBo retweeted
Replying to @badamczewski01
btw, I filed an issue to improve that chain of hash checks to something similar to Trie github.com/dotnet/roslyn/iss…
EgorBo retweeted
ARM adds hinted conditional branches as well as memcpy() and memset() instructions community.arm.com/developer/…
EgorBo retweeted
Parsing floating-point numbers really fast in C#
lemire.me/blog/2021/02/22/pa…
EgorBo retweeted
Continuing the what's the effect of upgrading to .NET 5.0; since the libraries are "unified" and it's been improved what's the effect on the Mono VM (llvm AoT) On @TFBenchmarks upgrading to Mono to .NET 5.0?
x6.4 to x17 times faster! Wow! #dotnet #aspnetcore
EgorBo retweeted
You can measure the speed of light at home using just a microwave and a bar of chocolate!
EgorBo retweeted
On @TFBenchmarks upgrading to .NET 5.0 (rc1)
(netcoreapp3.1 => net5.0)
Middleware is now faster than Platform was, and Platform is now much faster #aspnetcore #dotnet
EgorBo retweeted
A bit of reading during the containment, just published a new blog post about the development of the native compiler for #starklang
xoofx.com/blog/2020/03/21/st…
Next remaining one will about the integration with seL4 microkernel.
Stay tuned! 🤗






























