CoreWCF Streaming RPC Performance Bottleneck: A Stack Overflow Failure Postmortem

2025-05-08
CoreWCF Streaming RPC Performance Bottleneck: A Stack Overflow Failure Postmortem

The author attempted to use CoreWCF for streaming RPC between .NET Framework and .NET 8 to test the throughput of random number transfers. However, after posting a question on Stack Overflow, it was closed without an answer. The issue is that the CoreWCF service continues to consume significant CPU and write to the stream even after the client disconnects. The author suspects a misunderstanding of how WCF streams are supposed to work, suggesting WCF streams may not be suitable for handling streams of unknown length. The article explores the challenges of using WCF streaming for high-throughput RPC and considers alternatives, such as using single message requests or session mode, to improve performance and reliability.

Read more
Development

Span<T> Beats memcmp: Massive Performance Gains in .NET Byte Array Comparisons

2025-03-30
Span<T> Beats memcmp:  Massive Performance Gains in .NET Byte Array Comparisons

This post benchmarks various byte array comparison methods in .NET, including `memcmp`, looping, `Enumerable.SequenceEqual`, and `Span.SequenceEqual`. Results show `Span.SequenceEqual` offers the best performance in .NET 8 and later, significantly outperforming `memcmp` and traditional looping, even on .NET Framework. For small arrays, looping is fastest, but `Span.SequenceEqual`'s advantage grows dramatically with array size. The author recommends using `IEnumerable.SequenceEqual` in .NET 8+ and `Span.SequenceEqual` in .NET Framework, avoiding `memcmp` and custom implementations.

Read more
Development byte array comparison