WTF: Visualizing Builds to Find Performance Bottlenecks

2025-08-15
WTF: Visualizing Builds to Find Performance Bottlenecks

What the Fork is a cross-platform tool that visualizes the build process of any build system, helping developers identify and resolve performance bottlenecks. By monitoring system calls, it tracks process start and termination, generating an interactive visualization showing process timelines, commands, and arguments. The author demonstrates its power through examples from various projects, revealing issues like lack of parallelism and redundant operations. This allows developers to significantly optimize build times, particularly beneficial for CI builds.

Read more
Development build optimization

Beyond Dynamic Arrays: The Efficient and Stable Segment Array

2025-08-07
Beyond Dynamic Arrays: The Efficient and Stable Segment Array

This article introduces Segment Array, a high-performance data structure combining the flexibility of dynamic arrays, the advantages of stable pointers, and excellent compatibility with arena allocators. Unlike dynamic arrays that move elements during resizing, Segment Array uses pre-allocated segments of fixed sizes, avoiding memory fragmentation and pointer invalidation. Each segment is double the size of its predecessor, with new segments allocated only when needed, achieving O(1) average time complexity. The author provides a C implementation and details its inner workings, including efficient index calculation and integration with generics. Segment Array is particularly useful in scenarios requiring efficient dynamic memory management within an arena allocator, such as in a build profiler.

Read more
Development

Type-Safe Generics in C: A Clever Use of Unions

2025-07-01
Type-Safe Generics in C: A Clever Use of Unions

This article presents a technique for implementing type-safe generic data structures in C using unions to associate type information with a generic data structure. The author illustrates the approach with a linked list, showing how macros and unions enable compile-time type checking, avoiding the type-unsafety and code bloat of traditional generic methods. Comparisons are made with `void*` and flexible array member approaches, culminating in a solution that provides compile-time type safety, resulting in compiler errors when incorrect types are added.

Read more
Development

Cracked Sudoku: A New Sudoku Variant Based on Voronoi Diagrams

2025-03-13
Cracked Sudoku: A New Sudoku Variant Based on Voronoi Diagrams

Tired of traditional Sudoku? Cracked Sudoku is here! This new Sudoku variant uses irregular Voronoi diagrams as its game board. The rules remain familiar to Sudoku fans, but 'rows' and 'columns' are replaced by 'runs'—connected sequences of cells without repeating numbers. The shapes of these runs are determined by the Voronoi diagram, creating a unique solving experience. The author shares the design philosophy and algorithms, and calls for experienced puzzle constructors to collaborate on creating more sophisticated levels, injecting more vitality into this innovative game.

Read more

Rick in 240 Lines of Code: A Stunning GLSL Animation

2025-02-06
Rick in 240 Lines of Code: A Stunning GLSL Animation

This article details the author's eight-month journey creating a breathtaking Rick animation using only 240 lines of GLSL code, no libraries, and no images. The author embeds a live coding editor within the post, allowing readers to program their own animations. The process is explained step-by-step, from basic color fills to using signed distance functions (SDFs) like Bézier curves, stars, and rounded rectangles to meticulously craft Rick's features and hair. Noise functions and time domain warping bring dynamic effects to Rick's hair and add random eye movements. The author shares various animation techniques, including looping values, switching drawn content, and noisy movement, providing complete code and explanations to empower readers to create their own GLSL animations.

Read more
Design code art