Bucket-split 40-bit hash table architecture for 800,000+ wildcard domain storage in PSRAM.
To fit nearly a million domains onto an embedded microcontroller, domains are stored as hashes rather than variable-length strings. The challenge with hashing is false-positive collisions where a legitimate domain's hash collides with a blocked entry. By increasing discrimination from 32-bit to 40-bit bucket-split hashing, the false-positive probability is drastically eliminated while reducing RAM footprint:
| Metric | 32-bit Hash | 40-bit Bucket-Split |
|---|---|---|
| Per-probe False Positive Rate | 1.8 × 10-4 | 7.1 × 10-7 |
| Per-query False Positive (4 suffixes) | ~1 in 1,500 | ~1 in 350,000 |
| Memory per Entry | 4 bytes | 3 bytes (+ 256 KB index) |
| Probes per Suffix Lookup | ~20 (binary search over n) | ~4 (search within one bucket) |
The bucket index carries the top 16 bits as array position rather than stored data, achieving higher discrimination with 25% fewer bytes per entry.
h40 = fmix64(fnv1a64(domain)) >> 24 40 bits total
bucket = h40 >> 24 16 bits -> index slot
rem = h40 & 0xFFFFFF 24 bits -> stored remainder (3 bytes BE)
The live in-memory table is stored as a single contiguous allocation in PSRAM, allowing an atomic pointer swap when a reload completes:
+---------------------------+
| idx[65537] : uint32_t | 262,148 bytes idx[b] = start offset of bucket b
| | idx[b+1] = end offset of bucket b
+---------------------------+ idx[65536] = total entry count
| entries : 3 bytes each | 3 * N bytes big-endian 24-bit remainders,
| | sorted ascending within each bucket
+---------------------------+
When resolving a domain (e.g. sub.ad.tracker.com):
ad.tracker.com, tracker.com).idx[bucket] and idx[bucket+1].On boot, if a FAT32 MicroSD card is present with a valid snapshot, the pre-sorted binary image is streamed directly into PSRAM in ~21 seconds, completely bypassing upstream feed downloads and sorting.