Developer reports 12,000-fold slowdown in SQLite JSON tokenization

A developer running a Rust-based chess analysis service reported that inserting roughly 40,000 JSON records into SQLite took several minutes. The operation fully occupied one CPU core, even though saving results had never become a bottleneck in earlier tests.
The project used cargo-zigbuild and zig cc for cross-platform builds because the sqlx crate required SQLite, which is written in C, to be compiled for the target platform. Linux builds used standard library functions supplied by Zig. According to the account, Zig developers are gradually replacing musl components with implementations written entirely in Zig as part of libzigc.
The developer traced the problem to a rewritten strspn implementation that first calculated the full length of its input string, and noted similar behavior in strcspn, strpbrk and strstr. As the tokenizer advanced through JSON, it repeatedly measured the remaining text. In the reported case, tokenizing a 1.2 MB JSON file was approximately 12,000 times slower, with the slowdown growing quadratically as file size increased.
The issue did not appear on the developer’s Mac, where SQLite was compiled without Zig. Initially, the developer stripped whitespace from JSON before processing it, substantially reducing tokenization costs. The developer subsequently moved Linux builds into Linux containers because it was unclear where else similar problems might occur.
Original source: habr.com ↗
Comments on source platforms
Rank is the maximum of the latest discussion counts. These are source metrics.
Хабр
- Discussion ↗: 36
Measured: 11 Nov 2026, 06:00 UTC