7f16c6e473
This ends up surprisingly tricky with sparse ids. I feel like I'm missing a simpler solution, but this at least proves an implementation is possible. The implementation here does a single pass through the attributes backwards (which should probably be changed from a linked-list), keeping track of the best matching tag/id while updating everything based on grows/shrinks. Once we find the source of the best id we adjust things back to the pending id space. The implementation here only works with some significant caveats: 1. This solution might be able to find the id weights by keeping track of a lower bound, but it would be difficult and add complexity, so we don't do it. Really lfsr_rbyd_pendinglookup is only going to be used in full traversals as a part of compaction/splitting, so weight can be derived trivially from neighboring ids. 2. We don't know the difference between grows/shrinks used to change a branch's weight and used to create/delete ids. This is a bit of a problem here, but we can work around it by assuming that non-destructive grows/shrinks are always on the lower edge of a weighted id. Fortunately this assumption is only needed for in-flight attrs in lfsr_rbyd_pendinglookup, so this is not a requirement on-disk or in future implemenations.