stable first version: https://lists.cpunks.org/pipermail/cypherpunks/2022-July/102291.html

attached appears to have comparable performance to first version. i tried to implement all the same approaches (did not check for certain), except without all the O(n) simplifications and updating the index every write to help decide when to flush. I noticed the branch merging code is never hit, should try to figure out what data would make it get used or if it is redundant or has a further mistake.