Tag.NET

Build a profiling harness before you benchmark

B

TL;DR: Before writing a benchmark, build a small profiling harness that makes the code path visible. Run it in Release mode, keep unrelated work out, add clear profiler snapshot points, and collect both memory and CPU evidence. Production code is a terrible place to start a performance investigation. There is too much happening at once. Not because production code is bad. Because it is alive. It has real configuration, real input/output, logging, retries, dependency injection, serialization...

Stop guessing: the performance loop for production code

S

TL;DR: A benchmark can tell you whether code got faster. It cannot tell you whether the code mattered. For that, use a loop: profile with a profiling harness, improve a hot path, benchmark and compare, profile again, then ship and observe production. The first benchmark I wrote looked deceptively easy. A class. A few attributes. A method. Run BenchmarkDotNet and get a table. It looked a lot like unit testing, which made me dangerously confident. That confidence did not survive contact with real...

Event Sourcing: Simple is often enough

E

This is the first post in a series about event sourcing. I’ll start with a very simple event sourcing implementation that is often good enough. Most of our event streams are implemented in this simple approach. In the following posts, the concepts will be extended to match additional requirements. I’ll touch on read models, consistency, long event streams, archiving, compensation, event skipping, lifetimes, and bi-temporal event sourcing. Every post will explain the concepts and our...

Tests are Documentation, or are they?

T

Yesterday evening, I gave a workshop titled “To test, or not to test” at the Software Crafters Zürich Meetup. In the workshop, we gathered reasons to write tests: being confident that the code works, being confident that regressions can be prevented, helping to drive the implementation, and having documentation of the system. Interestingly, when I prepared the workshop, I forgot about the documentation aspect of the tests. Here is why and why it matters.

Version Conflicts with NuGet Packages

V
Packages with .net core and NuGet Logo

Yesterday, I found myself face-to-face with a rather peculiar phenomenon that managed to consume a good hour of my time. As is often the case, the solution turned out to be surprisingly simple. With the intention of documenting this for future reference (especially for my future self), I am writing this short blog post. What happened? A colleague of mine updated XUnit in our solution and merged it into our main branch. When I pulled the new code locally and tried to restore the NuGet packages...

Using SRTP-Active Patterns in F#

U
Country codes mapping JSON

A few days ago, we embarked on the process of tidying up a particularly complex piece of code. It involved moving typical frontend code to the backend, as it was becoming too cumbersome and we felt more secure writing it in F# in the backend. (more on that in another blog post) After much of it was rewritten, we ran into a pattern matching construct that threatened to contain a lot of code duplication. To increase readability, we wanted to use an Active Pattern. The problem was that the...

Migrating NServiceBus from v5 to v6 – Injecting IMessageSession when using NServiceBus.Host

M

I’m on the way to migrating from NServiceBus v5 to v6, and currently using NServiceBus.Host. As changing everything at the same time would be too much risk, I decided to keep using NServiceBus.Host until the migration to v6 is completed. This post is only relevant if you’re using NServiceBus.Host to host your endpoint. NServiceBus.Host for v6 does not register the NServiceBus interfaces (e.g. IMessageSession) on the dependency injection container anymore. During startup of the...

Recent Posts