The 1 trillion pixel maze my decade long obsession with C# optimization - Davy Davidse

The 1 trillion pixel maze my decade long obsession with C# optimization - Davy Davidse

🎙 Davy Davidse 👥 231K 📅 November 24, 2026 ⏱ 48 min 👁 16 📄 expert opinion 🧭 2026-11-24
Available in: English (current) Français

Keywords

maze generationbacktracking algorithmbit arraystruct layoutaggressive inliningbranch predictionmemory optimizationperformance tuningXORShiftgeneric specialization

Summary

In this talk at NDC Oslo, Davy Davidse recounts his decade-long journey to create the world’s largest maze—a 1-trillion pixel maze—through relentless C# optimization. He begins by explaining basic maze generation using a backtracking algorithm and depth-first search for pathfinding. The initial implementation used a 16,000×16,000 array with enums, consuming 1 GB per maze. He then applies easy fixes: switching to booleans, then BitArray, and packing points using StructLayout to reduce memory. To generate larger mazes, he adopts a hybrid approach, keeping only a grid of recent memory segments and swapping to disk, enabling a 1-million-pixel maze with 137 GB storage. He discusses the path storage using a ‘QuattroStack’ that compresses directions into bits and uses lazy IEnumerable to avoid holding the entire path. For the fastest generation, he challenges his baseline of 3.27 seconds for 16,000×16,000, employing .NET Core, aggressive inlining, XORShiftRandom, and a clever generic specialization technique to eliminate overhead from debug drawing. He shares performance statistics: 18.5 hours to generate the 1M maze, 577 million decisions, and 18 billion steps. He also details his struggle to view the huge output image, eventually building custom pyramid tools with OpenSeadragon and Libvips. The talk concludes with his lessons on micro-optimizations and a humorous, self-aware tone.

206 words

Critical Evaluation

Value of the Information & Strength of the Argument

The talk excels in demonstrating the practical application of low-level optimizations in C#. The speaker provides concrete examples, performance numbers, and explains the rationale behind each technique, such as the impact of branch prediction and the cost of null checks. The argumentation is persuasive, especially his approach to keeping debug code with zero overhead via generic struct specialization. The use of real-world results (generation times, memory usage) strengthens the value. The narrative is engaging, but sometimes he loses focus on the core optimization techniques to share personal anecdotes, which is entertaining but slightly dilutes the technical density.

Scientific Rigor, Source Quality, Title Accuracy

The talk is based on personal experimentation and does not cite external academic sources. The only references are conference links (NDC) and tools like GigaPan, OpenSeadragon, and Libvips, which he mentions but does not provide URLs for. The title is accurate, and the content aligns well with the promised focus on C# optimization. The technical claims are plausible but not verified by independent benchmarks in the talk. The structure is clear, though the demonstration of the 1 trillion pixel maze failed due to network issues, which was admitted honestly. Overall, the presentation is rigorous in its methodology but lacks external validation.

213 words

Title / Content Match

The title accurately reflects the content: a personal narrative about creating a trillion-pixel maze through intensive C# optimizations.

Quality & Reliability

8/10

The talk provides a detailed, well-structured account of algorithmic and memory optimisations backed by concrete metrics. The speaker demonstrates deep first-hand experience, though the content is anecdotal and not peer-reviewed. The technical explanations are clear and the claims are plausible, but lacking formal validation.

Key Moments

Cited Sources

  • NDC Conferences — The talk was recorded at NDC Oslo, and the speaker mentions attending the conference and encourages others to attend.
  • NDC Oslo — Specific conference website for Oslo, mentioned in the description as the event where the talk was recorded.

Contribution & Novelties

The talk presents a unique approach to generating extremely large mazes through a series of incremental optimizations. The key novelty lies in combining memory-efficient data structures (BitArray, struct packing) with algorithmic improvements (QuattroStack path compression, lazy IEnumerable) and micro-optimizations (aggressive inlining, XORShiftRandom, generic specialization). The speaker demonstrates that even in .NET, it is possible to handle terabyte-scale data with careful engineering. The talk also introduces a technique to keep debug code without performance penalty using generic structs.

Pour aller plus loin :

165 words

Radar Profile

The radar chart shows high scores in quantity and quality of information, reflecting the detailed technical content and clear explanations. The technical level is high but accessible. Fiabilité is moderately high, given it's a personal account without external validation. The overall profile suggests a solid, educational talk with some limitations in scientific rigor.

Reliability 7/10