All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Bijou64: A variable-length integer encoding that's both correct and accidentally fast

By

justinweiss

19h ago· 11 min readenInsight

Summary

This article describes the development of bijou64, a variable-length integer (varint) encoding created for the Subduction CRDT sync protocol. The encoding was designed to fix a signature-verification bug by ensuring each number has only one possible representation (canonical encoding). An unexpected side benefit was that bijou64 runs several times faster than the more common LEB128 varint encoding. The author explains how the design constraints for correctness inadvertently led to performance improvements by requiring less computational work during encoding and decoding.

Key quotes

· 4 pulled
It's nice when you work on security and accidentally get some performance for free.
We didn't set out to write a fast varint, but it turns out that our design constraints made for an encoding that has to do less work.
It was intended to fix a subtle signature-verification bug by making each number only representable a single way.
It turned out to also run a few times faster than the more common varint LEB128.
Snippet from the RSS feed
An accidentally fast variable-length integer encoding

You might also wanna read