Skip to content

Navigation Menu

Sign up

Generating a .see response efficiently

quartzjer edited this page Sep 13, 2010 · 7 revisions

All "visible" (that have sent themselves back in a .see) lines are stored in kbuckets, an array of 160 buckets (one per bit, 160 bit hash), each bucket itself being an array containing the lines in that bucket.

A line is assigned to a bucket based on it’s "distance" from us (binary xor of it’s +end and our +end hashes), 50% on average would be the furthest away and be in the first bucket (bucket 0 or bucket 159, should we suggest an ordering to help make sense across implementations?) as they differ on the first bit. Closer ones would be in buckets closer to us. The goal of seeding is to fill as many of the buckets as close to us as possible, so that we can more efficiently respond to +end requests in our vicinity with other switches closer to it.

When a new +end comes in and needs to be responded to with a list of other switches closer to it than us, we first find it’s distance from us and take that bucket of switches, as they would all be the same distance from it (all share the same xor bytes up to that bucket). If we don’t have enough in that bucket, we gather more from buckets closer to us (which may or may not be closer to it but are all closer than buckets further from us). If we still don’t have enough, we start stepping up buckets further from us, until we have at least a few switches, which we then sort based on their distance from the incoming +end, and generate a .see response with those few closest to it.

Maybe:

Every switch has a "see cache" that lists the closest few other switches to itself. A "refresh" function that walks that cache, and gets the caches from each, re-sorts and updates the local cache with the closest (removing any dead ones). An empty cache, take /any/ switch and recurse down it’s cache until you find the switch closest and clone it.

Any incoming +end would also do the recurse-to-closest-switch, and then cache that mapping (ends are very often repeated). It would then "refresh" based on that cache and that +end.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /