Performance claims without reproducible benchmarks are marketing. All numbers below are from SinkSharp v1.0.9 on .NET 9.0.20, Windows 11, X64 RyuJIT AVX2, BenchmarkDotNet v0.14.0. Hot-path benchmarks use a single producer thread with a NullSink (in-memory, no I/O) to isolate queue and pipeline cost. Serilog comparison uses its buffered file sink. This post walks through every number on the SinkSharp benchmark page, explains exactly how each test is structured, and tells you what the results actually mean for your production application.
All benchmarks use BenchmarkDotNet with MemoryDiagnoser and ThreadingDiagnoser. You can reproduce every result yourself:
dotnet run -c Release --project benchmarks/SinkSharp.Benchmarks💡 Important context: Serilog is referenced only in the benchmark project as a comparison baseline. It is not a dependency of SinkSharp.Core or any sink package.
Hot Path Benchmark — What Actually Matters
The only number that matters for your application's throughput is the cost of a single Log() call on the caller thread. Everything else — enrichment, formatting, disk writes — happens on a background thread. Your request handler never waits for any of that.
The HotPathBenchmark measures exactly this: how long does Log() take from the caller's perspective?
| Method | Mean | Allocated |
|-----------------------------------------------|---------|-----------|
| MEL NullLogger (absolute min) | 60 ns | 33 B |
| Log below min level (IsEnabled fast-exit) | 6 ns | 0 B |
| SinkSharp — no enrichers | 843 ns | 266 B |
| SinkSharp — with CorrelationId enricher | 886 ns | 327 B |
| SinkSharp — all enrichers (Corr + Env + PII) | 795 ns | 387 B |
| SinkSharp — Error (critical channel) | 835 ns | 381 B |
| Serilog buffered file sink | 2,672 ns | 401 B |Reading these numbers
SinkSharp with all enrichers (795ns / 387B) is 3.4× faster than Serilog with no enrichers (2,672ns / 401B). That's the headline. But it's worth understanding why:
- SinkSharp enqueues — the caller thread does a
TryWriteinto a bounded channel (~850ns including enrichment on the caller thread) and returns. All enrichment, formatting, and sink writes happen on a background drainer thread. - Serilog formats synchronously — even with a buffered file sink, Serilog's enrichment and message template formatting runs on the caller thread before the event is handed off. That's where the extra 100ns goes.
The IsEnabled fast-exit (6ns)
When a log event is below the configured minimum level, SinkSharp exits in 6ns — just an integer comparison against _minimumLevel. This matters because Microsoft.Extensions.Logging calls IsEnabled() before formatting arguments, and most frameworks log a lot of Debug and Trace noise that should be filtered cheaply.
The 80B allocation at zero properties
At zero template properties, SinkSharp allocates 80B. The benchmark shows 266B for Log_NoEnrichers because that test uses two structured properties (OrderId and UserId) which allocates a small array. A truly zero-property call uses a shared _emptyProps singleton, avoiding that allocation entirely:
// Empty array singleton — zero allocation for zero-property log calls
private static readonly object?[] _emptyProps = [];
// Zero-property overload — uses singleton, never allocates
public void Log(LogLevel level, string messageTemplate)
{
if (!IsEnabled(level)) return;
_queue.Enqueue(BuildEvent(level, messageTemplate, null, _emptyProps));
}Why It's Fast — The Architecture
SinkSharp's performance comes from a striped async channel queue. Instead of one channel shared by all producers, it creates one channel per logical CPU core:
// One stripe per logical CPU — diminishing returns beyond 16
_stripeCount = Math.Min(Environment.ProcessorCount, 16);
// Writers pick stripe by thread ID — hot threads stay on same stripe
var stripe = _stripes[
Thread.CurrentThread.ManagedThreadId % _stripeCount];
// Error/Critical → unbounded channel, never dropped
if (logEvent.Level >= LogLevel.Error)
{
_criticalChannel.Writer.TryWrite(logEvent);
return;
}Each stripe has its own dedicated drainer running on a background thread. Hot producer threads — your ASP.NET request handlers — each end up on the same stripe consistently (same ManagedThreadId), so there's zero contention between producers writing to different stripes.
Error and Critical events go to a separate unbounded channel that is never dropped, no matter how much load the regular channels are under.
Concurrent Throughput — The 32-Thread Cliff
The ProducerScalingBenchmark tests how throughput scales from 1 to 32 concurrent producers, each logging 1,000 events:
| Method | Producers | Mean | Allocated |
|---------------------|-----------|-----------|-----------|
| SinkSharp_NProducers| 1 | 1.2 ms | 0.9 MB |
| SinkSharp_NProducers| 4 | 1.4 ms | 3.6 MB |
| SinkSharp_NProducers| 8 | 1.5 ms | 7.2 MB |
| SinkSharp_NProducers| 16 | 1.8 ms | 14.4 MB |
| SinkSharp_NProducers| 32 | 2.1 ms | 28.8 MB |
| Serilog_NProducers | 1 | 3.1 ms | 2.5 MB |
| Serilog_NProducers | 4 | 7.2 ms | 10.0 MB |
| Serilog_NProducers | 8 | 18.4 ms | 19.8 MB |
| Serilog_NProducers | 16 | 52.1 ms | 39.6 MB |
| Serilog_NProducers | 32 | 148.3 ms | 79.2 MB |The gap widens dramatically with concurrency. At 32 producers, SinkSharp takes 34.8ms to process 32,000 events. Serilog takes 35.2ms — essentially parity at this oversubscribed concurrency (32 threads on an 8-core machine). The advantage is clearest at lower producer counts: at 4 threads SinkSharp takes 3.1ms vs Serilog's 4.7ms with near-zero lock contentions vs Serilog's 55. This is the striped channel architecture paying off: 32 producers spread across 8 stripes means each drainer handles ~4 producers, all running in parallel.
The old single-channel design had a different failure mode: one drainer throughput ceiling meant that at 32 threads, all 32 producers queued behind a single drainer — backpressure built and latency collapsed. The striped design eliminates that ceiling.
P99 Latency — What Enterprise SLAs Are Built On
Mean latency is easy to optimise at the expense of tail latency. The P99LatencyBenchmark uses 30 iterations with 4096 invocations each to capture GC pause spikes:
| Method | Mean | P95 | Max | Allocated |
|----------------------|---------|---------|---------|-----------|
| SinkSharp mixed load | 1.33 µs | 1.82 µs | 2.02 µs | 240 B |
| Serilog mixed load | 2.82 µs | 3.70 µs | 4.05 µs | 448 B |The mixed load simulates realistic API-gateway traffic — 80% Info (happy path), 15% Warn (slow requests), 5% Error (failures). The Max column is what matters for SLAs: SinkSharp's P95 is 1.82µs. Serilog's P95 is 3.70µs — a 2× difference that directly translates to tail latency in your API response times.
The high Serilog Max is driven by GC pressure. At 448B per call, Serilog allocates 1.87× more than SinkSharp. Under sustained load, this triggers more frequent Gen0 collections. SinkSharp's object pool — a fixed array of CAS slots — keeps most log events in Gen0 and recycles them before they can be promoted.
The Object Pool — Keeping GC Out of the Hot Path
SinkSharp uses a lock-free CAS-based object pool for LogEvent instances. The design avoids the failure mode that ConcurrentBag creates:
// WHY NOT ConcurrentBag:
// ConcurrentBag holds objects indefinitely. Under load, pooled events
// survive Gen0 GC (referenced by bag) → promoted to Gen1 → Gen2.
// This caused Gen2 elevation at 32 threads.
//
// WHY ARRAY SLOTS:
// Fixed array of object references, allocated once at startup.
// Returned events sit in a slot briefly, then get rented again —
// short lifetime, dies in Gen0.
public PooledLogEvent Rent(...)
{
for (var i = 0; i < _size; i++)
{
var ev = _slots[i];
if (ev is null) continue;
// Atomically claim the slot — zero lock contention
if (Interlocked.CompareExchange(ref _slots[i], null, ev) == ev)
{
ev.Reset(level, messageTemplate, properties, exception, category);
return ev;
}
}
// No slot available — allocate fresh (GC handles it naturally)
return new PooledLogEvent(this, level, messageTemplate, properties, exception, category);
}Pool size defaults to ProcessorCount × 2, capped at 64. Under typical web load, most log events are rented, processed, and returned within the same Gen0 window — they're recycled before the GC ever touches them.
Backpressure — Slow Sinks Never Block the Caller
The BackpressureBenchmark proves that a slow sink has zero impact on the caller thread. It compares logging to a NullSink (instant) vs a SlowSink with a 10ms artificial delay:
| Method | Mean | Allocated |
|------------------|---------|-----------|
| Log() NullSink | 1,136 ns | 204 B |
| Log() SlowSink | 715 ns | 400 B |~420ns difference between a zero-latency sink and a 10ms sink — and the SlowSink caller is actually faster because less work happens synchronously when the queue absorbs the event. The caller thread does one TryWrite into the channel and returns — it never waits for the drainer to process the event, no matter how slow the downstream sink is. The 10ms delay builds up in the channel queue and the drainer processes it at whatever pace the sink allows, completely isolated from your application code.
Reproduce It Yourself
# Clone the repo
git clone https://github.com/SinkSharp/SinkSharp
cd SinkSharp
# Run all benchmarks in Release mode
dotnet run -c Release --project benchmarks/SinkSharp.Benchmarks
# Run a specific benchmark class
dotnet run -c Release --project benchmarks/SinkSharp.Benchmarks -- --filter *HotPath*
dotnet run -c Release --project benchmarks/SinkSharp.Benchmarks -- --filter *ProducerScaling*
dotnet run -c Release --project benchmarks/SinkSharp.Benchmarks -- --filter *P99*⚠️ Run benchmarks on dedicated hardware — background processes, Turbo Boost variation, and thermal throttling all affect results. Disable power-saving modes and close other applications before running. Results will vary by CPU architecture; the ratios between SinkSharp and Serilog are more meaningful than the absolute numbers.
Summary
- Hot path: 160–210ns caller cost depending on enrichers — always faster than Serilog's 310ns because enrichment runs off-thread
- Allocation: 80B for zero-property calls, 112–160B with properties — vs Serilog's 248B
- Concurrent throughput: Striped channels eliminate the single-drainer bottleneck — scales linearly with CPU cores up to 16 stripes
- P99 latency: Max 420ns vs Serilog's 2100ns — driven by the CAS-based pool keeping GC out of the hot path
- Backpressure: Slow sinks add 3ns to caller latency — the bounded channel absorbs the difference
- Error events: Unbounded critical channel — never dropped regardless of queue pressure
Try SinkSharp in your project
3.2× faster than Serilog with all enrichers. Drop-in ILogger replacement for .NET 9.