3 ms·
You don't need a total order for the locality properties. E.g. a 32bit ms timestamp that overflows every ~50 days + 96bit of entropy will give you the same loca
by j-pb 2y ago
You don't need a total order for the locality properties. E.g. a 32bit ms timestamp that overflows every ~50 days + 96bit of entropy will give you the same locality with a much lower collision probability.
That being said, a lot of index types don't care about this kind of locality and might even benefit from higher entropy (randomized algorithms).
- s4i 2y agoDepending on your read and write patterns, overflowing even every few days might be appropriate, and also obfuscate the creation time [1] more. [1] https://news.ycombinator.com/item?id=40272446 https://news.ycombinator.com/item?id=40272446
- j-pb 2y agoGreat point, using a u16 is probably the best choice then. As it give locality within 65.53600 seconds (roughly a minute) without exposing sensitive timing information, and should cover most real world write scenarios.
- j-pb 2y agoA small additional improvement might be to also create a random 16bit salt at startup and then xor the timestamp with that, to leak even less information. That way entries will still have locality without leaking ms timestamp info.