Speaker Notes

Performance

Memory, latency and making software fast.

6talks
74answers
2mainly about it
6new
DecJanFebMarAprMayJunJulAugSepOctNov

What your library answers 74

How did Microsoft Windows become a gaming platform?

Early versions of Windows lacked the fast CPU pixel-filling and display negotiation needed for games, so developers like Chris Hecker created a skunkworks library called WinG to enable fast screen blitting. This unapproved graphics add-on served as the direct institutional and technical precursor to DirectX, which eventually established Windows as a dominant gaming platform. Although management volatility temporarily disrupted the project, it successfully proved that Windows could handle high-performance graphics.

Thumbnail: Why performant code matters (but gets widely ignored), with Casey Muratori ▶ 8:07 Why performant code matters (but gets widely ignored), with Casey Muratori

What makes Rust a good choice for systems programming?

Rust is a compiled, memory-safe programming language that combines high-level simplicity with low-level performance. It is commonly used for building systems where performance is critical, such as game engines, databases, operating systems, and web assembly targets.

Thumbnail: Rust in 100 Seconds ▶ 0:00 Rust in 100 Seconds

How did you approach building the backend message threading for Gmail?

Peter and the team utilized B-trees and inverted search indices to handle message threading and unread counts right from the start. This architecture supported fast lookups despite the constraints of early distributed systems.

Thumbnail: Distributed databases with Peter Mattis ▶ 12:18 Distributed databases with Peter Mattis

Why do standard unit and integration test suites miss critical production bugs?

Standard test suites only check components in isolation and rely on situations developers have actively anticipated. Production failures are usually caused by environmental factors, weird timing, or complex interactions that engineers never thought to test for.

Thumbnail: From Unit Tests to Whole Universe Tests (with Will Wilson) ▶ 0:22 From Unit Tests to Whole Universe Tests (with Will Wilson)

Why does tokenization cause weird issues like poor spelling or arithmetic in LLMs?

Tokenization acts as the fundamental boundary layer for text, meaning that string manipulations and non-English text are often poorly represented. Simple tasks like spelling or arithmetic fail because the model sees arbitrary subword chunks instead of characters or proper words.

Thumbnail: Let's build the GPT Tokenizer ▶ 4:32 Let's build the GPT Tokenizer

How do I inspect the tensor shapes of the original GPT-2 checkpoint?

You can load the model using Hugging Face Transformers and extract its state dictionary to inspect key-value tensor shapes. This reveals the dimensions of components like the 50257-by-768 token embedding lookup table.

Thumbnail: Let's reproduce GPT-2 (124M) ▶ 5:38 Let's reproduce GPT-2 (124M)

Why do most engineering teams and developers ignore software performance?

Developers often overlook performance because enterprise software purchasers care more about compliance and cost than speed, and monopoly network effects make responsiveness secondary to user acquisition. Furthermore, a general lack of awareness regarding hardware limits leads to poor benchmarking and bloated software budgets. However, recent trends show that startups using performance-based pitches are starting to gain traction against sluggish incumbents.

Thumbnail: Why performant code matters (but gets widely ignored), with Casey Muratori ▶ 17:19 Why performant code matters (but gets widely ignored), with Casey Muratori

How does Rust handle memory management without a garbage collector?

Rust achieves memory safety through a system of ownership and borrowing instead of using a garbage collector. By default, variables are immutable and stored on the stack, while mutable values or unknown sizes go to the heap. When a variable goes out of scope, its allocated memory is dropped automatically.

Thumbnail: Rust in 100 Seconds ▶ 0:40 Rust in 100 Seconds

Why did Colossus transition from traditional replication to Reed-Solomon erasure coding?

Traditional replication required storing three identical copies of data, which consumed excessive storage space. Reed-Solomon erasure coding allowed the system to store data much more efficiently while still allowing data reconstruction if multiple chunks were lost.

Thumbnail: Distributed databases with Peter Mattis ▶ 19:24 Distributed databases with Peter Mattis

How do you specify high-level invariants for a massive distributed system without going crazy?

You start with a small number of basic properties like ensuring the system never crashes or times out. As you go deeper, you can turn formal API guarantees and written SLAs into automated test properties.

Thumbnail: From Unit Tests to Whole Universe Tests (with Will Wilson) ▶ 8:08 From Unit Tests to Whole Universe Tests (with Will Wilson)

Why do non-English languages and Python code waste context window space in GPT-2?

GPT-2's tokenizer breaks non-English text and Python indentation spaces into many small, separate tokens. This bloats the sequence length and causes the model to run out of context length during attention.

Thumbnail: Let's build the GPT Tokenizer ▶ 10:27 Let's build the GPT Tokenizer

How are positional embeddings structured in GPT-2 compared to the original Transformer?

Unlike the original Transformer which used fixed sinusoidal functions, GPT-2 treats positional embeddings as trainable parameters initialized randomly from scratch. During optimization, these embeddings organically develop smooth sinusoidal and cosine structures.

Thumbnail: Let's reproduce GPT-2 (124M) ▶ 7:28 Let's reproduce GPT-2 (124M)

How should I actually approach optimizing software performance?

True optimization requires identifying the theoretical peak capabilities of the underlying hardware and measuring the performance delta against your current implementation. Relying solely on a profiler to find big bottlenecks only traps you in local minima without knowing what the machine is truly capable of achieving. Calculating theoretical maximums also helps engineers discover hardware anomalies and continuously learn about modern CPU architectures.

Thumbnail: Why performant code matters (but gets widely ignored), with Casey Muratori ▶ 24:01 Why performant code matters (but gets widely ignored), with Casey Muratori

What is borrowing in Rust?

Borrowing allows parts of a program to access a reference in memory without taking ownership of it. The Rust borrow checker validates a strict set of rules at compile time to ensure code safety while maintaining performance control.

Thumbnail: Rust in 100 Seconds ▶ 1:13 Rust in 100 Seconds

Why are B-trees often preferred over binary trees for memory performance?

Standard balanced binary trees cause frequent cache misses because every node traversal jumps to a different cache line. B-trees improve spatial locality and reduce pointer overhead by packing multiple sorted items into a single node. This structure allows more compact storage and faster linear scans or binary searches over items.

Thumbnail: Distributed databases with Peter Mattis ▶ 31:08 Distributed databases with Peter Mattis

Why do relaxed specifications make property-based tests more maintainable than traditional UI tests?

Traditional tests rely on rigid sequences of steps that break when completely incidental changes occur. Property testing checks general rules and invariants, meaning incidental updates like level layouts or timing don't automatically break your tests.

Thumbnail: From Unit Tests to Whole Universe Tests (with Will Wilson) ▶ 12:45 From Unit Tests to Whole Universe Tests (with Will Wilson)

Why can't we just use raw Unicode code points directly as inputs to language models?

While Unicode provides integers for characters, the standard encompasses roughly 150,000 characters and is constantly changing. Using them directly would create an unstable vocabulary and an unnecessarily large embedding space.

Thumbnail: Let's build the GPT Tokenizer ▶ 17:52 Let's build the GPT Tokenizer

What architectural changes did GPT-2 make to the original Transformer layer normalization?

GPT-2 moves the layer normalizations before the attention and multi-layer perceptron blocks rather than after them. It also adds an extra layer normalization right before the final classification head to maintain a clean residual stream.

Thumbnail: Let's reproduce GPT-2 (124M) ▶ 14:29 Let's reproduce GPT-2 (124M)

Why should I learn assembly language if I never write it?

Reading assembly is essential because it reveals the exact instructions the CPU is being asked to execute, unlike high-level languages which only show input to a compiler. It is surprisingly simple, requiring you to learn only a small subset of instructions that compilers actually output. Once you know it, you can read hardware architecture diagrams and understand CPU performance directly.

Thumbnail: Why performant code matters (but gets widely ignored), with Casey Muratori ▶ 27:37 Why performant code matters (but gets widely ignored), with Casey Muratori

How do I create and run a new project?

You can get started by installing Rust and using its package manager, Cargo. Running cargo new from the command line creates a new package, where individual packages are known as crates.

Thumbnail: Rust in 100 Seconds ▶ 1:27 Rust in 100 Seconds

How do distributed databases differ fundamentally from distributed storage systems?

Distributed storage systems like Colossus target large, immutable, append-only files such as 64-megabyte or gigabyte chunks. In contrast, distributed databases like Spanner manage relational tables with billions of typed rows and columns requiring frequent updates. Databases are typically built on top of distributed storage systems, using immutable files and log-structured merge trees to handle updates.

Thumbnail: Distributed databases with Peter Mattis ▶ 44:53 Distributed databases with Peter Mattis

How does the hypervisor run unmodified Linux deterministically without modifying the kernel?

The hypervisor implements a deterministic machine model underneath standard Linux so operations always take predictable clock cycles. When the system attempts a non-deterministic call like getting a random number, the hypervisor traps it and returns a deterministic answer.

Thumbnail: From Unit Tests to Whole Universe Tests (with Will Wilson) ▶ 22:30 From Unit Tests to Whole Universe Tests (with Will Wilson)

How does the Byte Pair Encoding algorithm compress text sequences?

BPE iteratively scans a sequence to find the most frequently occurring pair of tokens. It then mints a new vocabulary token for that pair and replaces all instances of it throughout the sequence.

Thumbnail: Let's build the GPT Tokenizer ▶ 24:16 Let's build the GPT Tokenizer

Which activation function does GPT-2 use in its MLP blocks?

GPT-2 uses an approximate version of the Gaussian Error Linear Unit activation function backed by a tanh approximation. This avoids the flat zero-gradient regions seen in standard ReLUs and provides smooth, continuous gradients during optimization.

Thumbnail: Let's reproduce GPT-2 (124M) ▶ 21:02 Let's reproduce GPT-2 (124M)

What is a false serial dependency chain and how does it hurt performance?

A serial dependency chain occurs when operations must happen in a specific order, such as waiting for a network request to finish before doing the next calculation. Because performance is determined by the longest un-parallelizable chain, this architectural pattern cannot be easily fixed by localized hotspot optimization. Avoiding it requires designing architectures that batch requests upfront and only chain when strictly necessary.

Thumbnail: Why performant code matters (but gets widely ignored), with Casey Muratori ▶ 34:21 Why performant code matters (but gets widely ignored), with Casey Muratori

How do I declare mutable variables in Rust?

Variables are declared with the let keyword and are immutable and unchangeable by default. To make a variable mutable so its value can be reassigned, you must add the mut keyword.

Thumbnail: Rust in 100 Seconds ▶ 1:41 Rust in 100 Seconds

How does contiguous key range sharding differ from basic hash-based sharding?

Basic hash-based sharding maps keys to a fixed number of shards using a hash function, which makes resharding and growing the table an onerous process. In contrast, systems like Cockroach DB use contiguous key spans across a single big key space, partitioning them with a B-tree-like index structure. This avoids full table remappings when adding nodes and places the sharding burden on the database rather than the developer.

Thumbnail: Distributed databases with Peter Mattis ▶ 52:40 Distributed databases with Peter Mattis

How does time-travel simulation speed up finding deep multi-step bugs?

Determinism allows the hypervisor to restart the simulation from the beginning and follow the exact same path without saving heavy state snapshots. Once a rare intermediate event is reached, the system locks it in and only explores further paths from that point onward, drastically reducing exponential search times.

Thumbnail: From Unit Tests to Whole Universe Tests (with Will Wilson) ▶ 33:57 From Unit Tests to Whole Universe Tests (with Will Wilson)

How do I replace a specific token pair across an ID list?

You iterate through the token list sequentially and check if the current and next positions match the target pair. If a match is found, you append the new replacement index and advance the pointer by two to skip the pair. Otherwise, you just copy the single element over and increment by one.

Thumbnail: Let's build the GPT Tokenizer ▶ 32:02 Let's build the GPT Tokenizer

How do I prepare text data into batches for Transformer training?

Tokenize the text into a sequence of integers and view it as a two-dimensional batch tensor. You should fetch an extra token beyond the sequence length so you can create parallel input and target tensors offset by one position.

Thumbnail: Let's reproduce GPT-2 (124M) ▶ 48:06 Let's reproduce GPT-2 (124M)