Just published Neyro.AppMetrics.Extensions.EventCountersCollector (https://t.co/pVjqeVYj6g) - AppMetrics's extension for collect EventCounter's data from EventSource's which supports it. E.g. RuntimeEventSource or NpgsqlEventSource. #appmetrics#netcore
Long time, no see, posting here several projects I worked on in the past months, as they got zero (re)post here: 😅
First, a new terminal UI framework https://t.co/brfEXOLWOi
I've published a new CLI tool to monitor outgoing HTTP requests in .NET applications.
Install it with: dotnet tool install -g dotnet-http
Download it from: https://t.co/hbUiqOZned
Run it with: dotnet http <pid>
Happy monitoring!
P.S. a blog post will be published soon ;^)
It looks like C# is finally getting discriminated unions.
And with it, you can expect to see language-level support for Result and Option types.
I'm excited to see this come to C#, as I've advocated for the Result pattern for quite some time.
In .NET 9 it's now possible to get an alternative lookup structure to search dictionaries and hashsets (and some other specialized collections) by spans. This allows for allocation free lookups!
#dotnet
Scan HTML faster with SIMD instructions: .NET/C# Edition
Recently, the two major Web engines (WebKit and Chromium) adopted fast SIMD routines to scan HTML content. The key insight is to use vectorized classification (Langdale and Lemire, 2019): you load blocks of characters and identify the characters you seek using a few instructions. In particular, we use ‘SIMD instructions’, special instructions that are available on practically all modern processors and can process 16 bytes or more at once.
The problem that WebKit and Chromium solve is to jump to the next relevant characters: one of <, &, \r and \0. Thus we must identify quickly whether we have found one of these characters in a block. On my Apple macbook, a fast SIMD-based approach can scan an HTML page at about 7 GB/s, with code written in C/C++.
But what about C#? The recent C# runtime (.NET8) supports fast SIMD instructions.
Let us first consider a simple version of the function:
This function just visits each character, one by one, and it compares it against the target characters. If one target character is found, we return.
Let us consider a SIMD version of the same function. It is slightly more complicated.
The function takes two pointers (ref byte* start and byte* end) that mark the beginning and end of the byte array. The main loop continues as long as start is at least 16 bytes away from end. This ensures there’s enough data for vectorized operations. We load in the variable ‘data’ 16 bytes from the memory pointed to by start. We use a vectorized lookup table and a comparison to quickly identify the target characters.The code checks if any element in matchesones is not zero. If there’s a match, then we locate the first one (out of 16 characters), we advance start and return. If no match is found, we advance by 16 characters and repeat. We conclude with a fallback look that processes the leftover data (less than 16 bytes).
I wrote a benchmark (in C#) that you can run if you have an ARM-based processor. It would be trivial to extend the benchmark to x64 processors.
Incredibly, the SIMD-based function is 15 times faster than the conventional function in these tests, and the accelerated C# function is just as fast, if not faster, than the equivalent C/C++ code.
In other words, .NET/C# allows you to write very fast code using SIMD instructions.
Blogged: Adding support for collection expressions to your own types - Behind the scenes of collection expressions - Part 5
https://t.co/vxH24OFOYV
In this post I show how to add support for collection expressions to your own types that don't support them
#dotnet#csharp
Had a go at making the code animate to fit the window, instead of shaping the window around the code.
Really like it - got this working faster than I thought.
But means I need to shape the content to prevent too much jumping around.
Probably old news now, but the CSS View Transition API is SUPER cool! Entry/exit layout animations like this used to be super complicated or require giant libraries. Now it's like 2 lines of JS, and a few lines of CSS if you want to customize the animation. Amazing! 🤯
💡 JavaScript tip(4):
`Intl` is a must-have in your JS toolbelt – it provides a powerful API for common language-sensitive functions, available to all browsers and JS server environments!
Here's how to use `Intl.RelativeTimeFormat()` to display relative time:
Finally added native https://t.co/h6LVSrOZJe.Pipelines support to System.Text.Json in .NET 9. This will allow us to remove unnecessary buffer copies when writing JSON to HTTP responses in Kestrel.
This change will be transparent if you're using https://t.co/PiydKAsC8g Core's APIs.
#dotnet #aspnetcore