C String Performance: Replacing O(n) Scans with VB-Style Descriptors

From: Clement Clarke

Date: Tue Mar 24 2026 - 05:14:32 EST


Linus,

The current industry-wide debate over Rust in the kernel often misses
a simpler path: we can make C both safer and significantly faster by
finally abandoning the null-terminator.

I have spent decades in the mainframe world (originating the Jol
language) and have ported a core architectural concept to modern C:
FastSafeStrings. By treating strings as length-prefixed, Variable
Blocked (VB) records rather than blobs of text, I’ve eliminated the
"Schlemiel the Painter" overhead inherent in string.h.

The Results:

0.2s vs 1.5s: In benchmarks processing 5 million records, my
descriptor-based I/O outperformed standard C fgets/getline logic by
over 700%.

No more strlen: Every string operation—concatenation, copying, and
slicing—is $O(1)$ or $O(m)$ because the metadata is carried with the
string.

Inherent Safety: By tracking capacity within the descriptor, buffer
overflows are programmatically prevented at the library level,
answering the safety concerns currently being used to push for
memory-managed languages.

We don't need a new language to fix the "C problem"; we just need to
stop the CPU from scanning for a \0 every time it touches a byte.

The implementation and benchmarks are available here:
https://github.com/clemcl/FastSafeStrings

Best regards,

Clement Victor Clarke clement@xxxxxxxxxxxxx