Shocking performance boost of assembly code: ~100x faster than C code | Lex Fridman Podcast
Developers from the FFmpeg/VLC ecosystem explain why handwritten SIMD assembly code can outperform C by 10-100x, using the AV1 decoder 'David' (240,000 lines of handwritten assembly) as a prime example. They argue that as Moore's Law slows and hardware gains plateau, low-level optimization becomes increasingly critical. The conversation challenges the widespread assumption that modern compilers with auto-vectorization can match hand-crafted assembly.
Summary
The conversation opens with a demonstration that handwritten assembly code achieved a 62x speed improvement over equivalent C code, challenging the common industry assumption that C is 'fast enough.' The speakers, who have built companies around the FFmpeg/VLC ethos, explain that most companies accept C as sufficiently performant, but significant gains remain on the table.
They discuss the extraordinary OS compatibility maintained by VLC and FFmpeg — supporting everything from Windows XP to Windows 11, Mac OS 10.7 to the latest versions, iOS 9, and even OS/2 — achieved by a very small team with fewer resources than Microsoft, Google, or Apple. Supporting legacy platforms like iOS 9 requires creative 'Frankenstein' builds combining multiple Xcode versions.
The technical core of the discussion focuses on SIMD (Single Instruction Multiple Data) assembly, which allows a single instruction to operate on a vector of 16 numbers simultaneously rather than one at a time — ideal for video processing on pixel grids. The speakers argue that handwritten SIMD consistently outperforms compiler-generated code and intrinsics by orders of magnitude, not merely a few percent, despite ongoing claims from the software community that modern auto-vectorization closes the gap.
The flagship example is 'David,' an open-source AV1 software decoder that is 79.9% handwritten assembly (240,000 lines) versus only 30,000 lines of C — described as likely one of the largest assembly codebases ever. David was created because the Alliance for Open Media (Google, Netflix, Amazon, Mozilla) claimed AV1 was too complex for software decoding, yet David achieves 720p decoding on just one or two CPU cores. It runs on roughly 3 billion devices, relevant given that 30% of Netflix and 50% of YouTube traffic is now AV1.
The speakers describe extreme low-level optimizations in David, including creating custom calling conventions that bypass standard OS conventions to avoid unnecessary register saves/loads, using cryptography instructions for unrelated video processing tasks, and implementing runtime CPU feature detection to set appropriate function pointers for each architecture (x86 AVX-512, ARM64, RISC-V, SVE, SME, etc.).
Philosophically, the speakers argue that the end of Moore's Law means hardware speed is no longer advancing rapidly enough to compensate for inefficient software. The value of low-level optimization will grow as AI inference, real-time processing, and cost constraints push developers back down the stack. They draw a parallel to LLM quantization (FP8, FP4, 1-bit weights) as another domain where hardware constraints force deep optimization. The conversation concludes with the assertion that vibe coding and AI-assisted programming will handle business logic, but hardware-level optimization remains something that cannot be automated away.
Key Insights
- A handwritten SIMD assembly function achieved a 62x speed improvement over equivalent C code, which the speakers cite as a concrete demonstration that C is not inherently fast and that compiler auto-vectorization is 'not even close' — not 5-10% slower but multiple times slower.
- The AV1 decoder 'David' contains 240,000 lines of handwritten assembly versus only 30,000 lines of C, making it likely one of the largest handwritten assembly codebases in existence, and was built because even the Alliance for Open Media (Google, Netflix, Amazon) claimed AV1 was too complex for software-only decoding.
- David deliberately violates standard OS calling conventions to avoid unnecessary register saves and loads to L1/L2 cache, instead defining its own internal calling convention — a technique the speakers say they have never seen in any other mass-deployed project running on billions of devices.
- The speakers argue that the end of Moore's Law fundamentally changes the calculus of software development: because hardware is no longer getting dramatically faster and adding more cores has limits, the value of low-level assembly optimization will increase as CPU, RAM, and networking constraints become binding.
- VLC and FFmpeg, maintained by a very small team, support more operating systems than Microsoft, Google, or Apple combined — including OS/2 which has roughly 10 users worldwide — with one maintainer among them, illustrating the ethos that optimization allows old hardware to remain useful rather than forcing unnecessary upgrades.
Topics
Transcript
[0:02] JB and I have started companies broadly speaking around the FFmpeg VLC ethos. So, that's really low-level work. So, so in most companies this this wouldn't be written in assembly. It would be accepted that C is C is fast. Um as you can see from that C is not fast. Uh so, here [snorts] it says 62 times faster than C. >> Yeah, so it's taking those the ethos of doing low-level programming, real-time programming, [0:33] and take using that for commercial applications. And JB and I have started companies around that. In many cases hiring developers from the open source community to use that ethos. And and so, that that's a great example of of some of…
Full transcript available for MurmurCast members
Sign Up to AccessMore from Lex Clips
How the Civil War ended | Gary Gallagher and Lex Fridman
Gary Gallagher and Lex Fridman discuss how the Civil War ended, focusing on Lee's surrender at Appomattox and Grant's magnanimous treatment of Confederate forces. They explore how Grant's generous surrender terms, influenced by Lincoln's reconciliation goals, contrasted with calls from Radical Republicans for harsher punishment and how this approach facilitated national reunification rather than perpetuating resentment.
White supremacy after the Civil War | Gary Gallagher and Lex Fridman
Historian Gary Gallagher discusses Reconstruction, white supremacy, and Confederate memory in post-Civil War America, emphasizing that Northern troops were insufficient to enforce equal rights for freed Black people, and explaining how the "Lost Cause" narrative allowed the South to reframe the war's purpose while Jim Crow became the mechanism for maintaining white supremacy.
The truth about the Civil War - Why people volunteered to fight | Gary Gallagher and Lex Fridman
Historian Gary Gallagher discusses the distinction between causation and motivation in Civil War volunteerism, explaining that while slavery caused the war, most Northern soldiers were motivated by belief in preserving the Union as a democratic republic. He emphasizes that understanding citizen-soldiers' sense of civic duty and American exceptionalism is essential to comprehending why ordinary people risked their lives for the Union.
Christianity and religion during the Civil War | Gary Gallagher and Lex Fridman
Both Union and Confederate sides during the American Civil War were overwhelmingly Protestant Christian and used religious justification for their military efforts. Interestingly, Confederate leaders like Lee and Jackson were notably more overtly religious in their official communications than Union commanders like Grant and Sherman.
Racism in America after slavery was abolished | Gary Gallagher and Lex Fridman
Gary Gallagher discusses how abolishing slavery was only the beginning of achieving equal rights for Black Americans, noting that most Northern whites prioritized saving the Union over ensuring racial equality. He explains that legal changes like the Civil Rights Act took over a century to achieve, while the deeper work of changing societal attitudes and prejudices remains ongoing and vulnerable to exploitation.