WHAT Was Too Slow?!? (When sprintf() Is A Performance Bottleneck)
summary
Identifies sprintf as a PostgreSQL export bottleneck and replaces divide-based digit counting with precomputed tables plus bit ops, cutting per-integer work to one clz, one table lookup, one add and one shift. Implements a 32-entry table for 32-bit integers (magic constants = differences of 2^n and 10^m), making printing branch-reduced and roughly 5% faster in benchmarks. Code targets PostgreSQL exports now and aims for upstream libc adoption.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 1:39Welcome
- 3:23Explanation
- 5:04Background
- 5:45Postgres
- 6:06Beta Export
- 8:53Daniel Lumiere
- 10:06Binary Integers
- 11:35Magic Numbers
- 12:57Fewer Instructions
- 13:34New Code
- 14:14Can We Get It Faster
- 15:31More Questions
- 16:04Nostalgia
- 17:07Questions
- 23:53Next Question
related talks
52mWriting fast C code for a modern CPU (and applying it to PostgreSQL)
25mPostgreSQL performance tips you have never seen before
26mWhere do the performance cliffs come from?
56mPerformance Improvements in PostgreSQL9 2
26mPostgreSQL performance tips you have never seen before V2.0
48mModern SQL features in PostgreSQL
43mPostgres Performance: From Slow to Pro
42mPostgreSQL is Nowhere Near Ready
