MariaDB performance analysis with Linux BPF
summary
Uses Linux BPF (BPFTrace then BCC) to attach uprobes to MariaDB do_command and tracepoints, running live on a 10,000-thread production box. Finds average queries ~500 µs but spikes of seconds; one commit spends 194 ms with 193 ms in kernel and ~190 ms waiting on futex waits caused by a custom reader/writer lock. Correlates buffer pool pagein and mutex holder across databases to a global lock bug fixed in 10.1.8; BPF script is public.
AI-written summary · about
chapters (23)
- 0:00Introduction to MariaDB BPF analysis
- 1:03Background on MariaDB at CM
- 2:05Identifying latency spikes in WordPress
- 3:10Initial troubleshooting with slow query log
- 5:20Exploring IO and buffer pool metrics
- 6:43Limitations of existing tools
- 7:04Introduction to Linux BPF
- 8:10Tracing MariaDB queries with BPF
- 9:16Measuring query execution time
- 9:59Kernel-level system call tracing
- 11:05Investigating write operations and futexes
- 12:07Discovering futex contention in MariaDB
- 13:15Analyzing slow queries with futex patterns
- 14:21Pinpointing the problematic futex
- 15:46Locating the source of the futex lock
- 16:09Researching MariaDB bug reports
- 17:12Implications of global locks in MariaDB
- 17:56BPF as a performance analysis superpower
- 18:40Overhead considerations for BPF
- 19:23BPF safety and production use
- 20:48BPF memory safety guarantees
- 21:32Why BPF is a game-changer
- 23:05Stack traces and frame pointers
