tokenbucket.c provides multithreaded lockless SWAR
(SIMD within a register) token bucket implementation using C11 atomics.
It’s used by the redbean web server to protect
our self-hosted production services from DDOS attacks. Based on our
experience, it foils attackers much more effectively than Cloudflare.
The basic idea here is you can allocate an int8_t
array with 2**24
items. Those are your buckets, where each bucket represents a block of
256 IP addresses, all of whom are assigned 127 tokens. Each time an IP
s