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.
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.
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.
Interface, base class, virtual, override, dynamic, reflection or expression trees — .NET gives you many ways to call a method, and their costs differ wildly. Full benchmark with numbers for each.
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.
Unity's Vector2/3/4 and Quaternion lack IEquatable and have a poor GetHashCode, which quietly murders performance the moment you put them in lists or dictionaries. Measurements, explanation, and the fix I reported to Unity.
Game loops check timers constantly, so how cheap is reading time? Environment.TickCount: 7ms for a million reads. DateTime.Now.Ticks: 1392ms. The numbers, and when each is the right choice.
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.
A small jQuery drop-in that turns tagged links into browser prefetch/prerender hints, so the next page loads instantly. Written as a quick fix for my increasingly slow blog — with warnings about what not to tag.
How well does Dictionary<int,int> actually perform? I measured speed and memory with random data and random access on real hardware — with numbers, graphs and a few surprises about what hides behind O(1).
For DSP debugging I want to draw FFT data fast: kernel32-allocated memory, unsafe pointers, and InteropBitmap so WPF renders straight from the buffer. Vacation-time code, constantly improving.
We run a development VM per customer at work, so making them fast matters. A long list of concrete tweaks for Virtual PC, VirtualBox and VMware — from disk layout to services worth disabling.
A good comparative performance test of antivirus products — some make a simple file copy take twice as long. Maybe disabling the antivirus now and then isn't such a bad idea.
One web.config attribute — optimizeCompilations="true" — makes ASP.Net recompile only what actually changed. Less waiting between test runs; links to the patches needed for older Windows versions.
A deep dive into user space threading for .NET: why OpenSim needs to pause, serialize and resume thousands of running scripts, and the whole arsenal — from Mono.Cecil IL rewriting to fibers — I have thrown at the problem.
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.
New detailed config options for DotNetEngine, and more importantly: maintenance, load/unload and execution threads can now be shared across regions instead of 3-4 threads per region — a big deal for large scale OpenSim installations.
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.
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.
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.