Logarithmically-Spaced Snapshots (2022)
madebyevan.com
madebyevan.com
Maybe not hard to get a deterministically good distribution (haven't properly read TFA) but I guess you'd be sad if you didn't do better than the most obvious thing.
I guess also an algorithm like "delete the (i mod n)th oldest element once you hit the capacity" also deletes every second element every n iterations, though maybe a bit uneven as it prefers to thin things out in quite local ways.
Given uniformly-spaced elements that preference might initially move the distribution in the direction of log-spaced, but it won't trend closely to it. (I think...)
Every day there is exactly one date for which a snapshot needs to be deleted and it can be computed directly. If there is no snapshot for this date nothing needs to be done.
- how long ago you need blocks for preventing alternate-history shenanigans
- how long ago you need blocks for nodes that may go offline for a while and come back confused
- how long ago you need fine granularity of records for accounting reasons
If none of those timespans are "forever" then maybe there could be agreement between nodes that at some point we start summarizing. So instead of deleting snapshots, you're merging adjacent blocks and purging transitional states that are not required to tell a consistent story.
Use case: I already have a list of equally spaced snapshots that I'd like to logarithmically space.
Also, it occurs to me that this (and other grandfather snapshot schemes) ultimately derive from the generational hypothesis: users want files for either a short time (transient files, tarballs, PDFs, checkouts) or a long time (photos).
- Start with the most recent snapshot; keep it
- Go on to the next snapshot; keep it, and then drop the next 2^1 - 1 = 1 snapshot
- Go on to the next snapshot; keep it, and then drop the next 2^2 - 1 = 3 snapshots
- Go on to the next snapshot; keep it, and then drop the next 2^3 - 1 = 7 snapshots
Etc.
Alternately (if it's easier to model or implement it thus), the snapshots that you keep are the ones at power-of-two indices, plus 0 (starting again from the most recent snapshot): snapshot 0, snapshot 1, snapshot 2, snapshot 4...
[1]: https://gist.github.com/Snawoot/9fdc348a8539cc74f80734180bd6...
(...GCAABBCDEEFFDG... might be interesting to write with the quatrains displayed block inline but the longer-range rhymes just set as normal prose; it would be up to the reader to notice the maintenance of metre and rhyme in the nominally "prose" sections)
What exactly is being optimized under what constraints and why log spacing is a solution ?