Oriel — AI & technology worth noticing, every day.

Shlemiel the Painter Is Back: How Zig's Libc Rewrite Made SQLite 12,000× Slower

Web page · https://dennisforbes.ca/blog/microblog/2026/10/the_accidental_12000x_sqlite_slowdown

First seen by Oriel on .

AI summary

A Rust chess-analysis service became unexpectedly CPU-bound because Zig’s rewritten libc functions repeatedly rescanned strings, making SQLite tokenization roughly 12,000× slower on Linux.

  • The service processes large batches of chess-game JSON and inserts approximately 40,000 records into SQLite, taking minutes instead of milliseconds.
  • Linux builds used zig cc through cargo-zigbuild, whose libzigc implementation replaced musl functions with pure Zig code.
  • Rewritten versions of strspn, strcspn, strpbrk, and strstr first measure complete string lengths, creating quadratic behavior during repeated tokenization.
  • Tokenizing a 1.2MB JSON file was approximately 12,000× slower with this pattern, and the slowdown increases as files grow.
  • The author reduced costs by pruning JSON whitespace, then moved Linux builds to containers because the broader impact was uncertain.

#sqlite #zig #rust #performance

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Points

Score reported by the source.

  • Hacker News: 16, latest observation ; +12 over observed period since
  • Lobsters: 106, latest observation ; +103 over observed period since

Comments

Comment count reported by the source.

  • Hacker News: 0, latest observation ; 0 over observed period since
  • Lobsters: 26, latest observation ; +26 over observed period since

Aliases

SourceExternal IDURL
Hacker News50367576https://dennisforbes.ca/blog/microblog/2026/10/the_accidental_12000x_sqlite_slowdown/ Read discussion
Lobsterslh1j0ehttps://dennisforbes.ca/blog/microblog/2026/10/the_accidental_12000x_sqlite_slowdown/ Read discussion