← All topics

20 articles in the notebook

Performance.

Unsafe reference arithmetic in .NET

A closer look at CompilerServices.Unsafe as the modern alternative to the fixed statement: doing reference arithmetic on GC-managed memory without pinning, what "unsafe" really means, and what the CLR does and doesn't promise you.

Why C# multidimensional arrays are slow

int[,] looks like the natural choice and performs like the wrong one. Digging into IL and JIT output to show what actually happens when you access single-dimensional, multidimensional and jagged arrays — and why the rectangular one loses.

Faster C# array access

Every array access in .NET pays for a bounds check — unless you convince the compiler it can skip it. I read the JIT'ed x64 assembly and benchmark tricks that make plain array access 18-34% faster.

Cost of method wrapper

What does a method that just calls another method actually cost? Using the == operator vs IEquatable.Equals as the guinea pig, I benchmark wrapper calls across compilers, JITs and runtimes — and read the disassembly to see why.

Better text console for C#

Console.MoveBufferArea turned out to be dead slow under heavy logging output. So I went to the Win32 console API and built a faster text console for C# — with source and benchmarks.

OpenSim tackles high load

3Di contributed region splitting and dynamic load balancing to OpenSim: multiple physical servers cooperating on one region, and regions migrating to less loaded machines while running. Green computing, virtual-world style.

Small stresstest

114 scripts loaded in-world, one AppDomain each, most of them firing timer events every second or every five — and my 2.8GHz Prescott doesn't break a sweat. Screenshots of the world and the performance graphs.

Speed

Script events now execute multithreaded — one object at a time, so multicore CPUs finally get used — plus cached event binding to avoid reflection on every call.

Looking ahead, fibres

Running thousands of scripts on a grid cannot mean one OS thread per script. Old ideas come to the rescue: cooperative multitasking à la Windows 3.11 and NT fibres, i.e. user space threading where each script carries its own execution state.