| | @@ -0,0 +1,263 @@ |
| 1 | +# Delta Manifests
|
| 2 | +
|
| 3 | +This article describes "delta manifests," a special case form of
|
| 4 | +checkin manifest which is intended to take up far less space than
|
| 5 | +a normal checkin manifest, in particular for repositories with
|
| 6 | +many files. We'll see, however, that the space savings, if indeed
|
| 7 | +there are any, come with some caveats.
|
| 8 | +
|
| 9 | +This article assumes that the reader is at least moderately familiar
|
| 10 | +with Fossil's [artifact file format](./fileformat.wiki), in particular
|
| 11 | +the structure of checkin manifests, and it won't make much sense to
|
| 12 | +readers unfamiliar with that topic.
|
| 13 | +
|
| 14 | +Sidebar: delta manifdebar">Do not coffuse these with the core [Fossil delta
|
| 15 | +format](./delta_format.wiki). This document describes an optional
|
| 16 | +feature not enabled by default.</div>
|
| 17 | +
|
| 18 | +This article describes "delta manifests," a special-case form of
|
| 19 | +checkin manifest which is intended to take up far less space than
|
| 20 | +a normal checkin manifest, in particular for repositories with
|
| 21 | +many files. We'll see, however, that the space savings, if indeed
|
| 22 | +there are any, come with some caveats.
|
| 23 | +
|
| 24 | +This article assumes that the reader is at least moderately familiar
|
| 25 | +wfth Fossil's [artifact file format](./fileformat.wiki), in particular
|
| 26 | +the structure of checkin manifests, and it won't maks much sense to
|
| 27 | +readers unfamiliar with that topic.
|
| 28 | +
|
| 29 | +# Background and Motivation of Delta Manifests
|
| 30 | +
|
| 31 | +A checkin manifest includes a list of every file in that checkin. A
|
| 32 | +moderately-sized project can easily have a thousand files, and every
|
| 33 | +checkin manifest will include those thousand files. As of this writing
|
| 34 | +Fossil's own checkins contain 989 files and the manifests are 80kb
|
| 35 | +each. Thus a checkin which changes only 2 bytes of source code
|
| 36 | +ostensibly costs another 80kb of storage for the manifest for that
|
| 37 | +change.
|
| 38 | +
|
| 39 | +Delta manifests were conceived as a mechanism to help combat that
|
| 40 | +storage overhead.
|
| 41 | +
|
| 42 | +# Makeup of a Delta Manifest
|
| 43 | +
|
| 44 | +A delta manifest is structured like a normal manifest (called a
|
| 45 | +"baseline" manifest) except that it has *two types of parents*: the
|
| 46 | +P-card which is part of (nearly) every manifest and a so-called
|
| 47 | +baseline (denoted by a B-card). The P-card tells us which artifact(s)
|
| 48 | +is/are the parents for purposes of the SCM version DAG. The B-card
|
| 49 | +tells us which manifest to use as a basis for this delta. The B-card
|
| 50 | +need not be, and often is not, the same as the P-card. Here's an
|
| 51 | +example:
|
| 52 | +
|
| 53 | +```
|
| 54 | +B c04ce8aaf1170966c6f8abcce8b57e72a0fa2b81
|
| 55 | +C Minor\sdoc\supdates...
|
| 56 | +D 2021-03-11T18:56:24.686
|
| 57 | +F bindings/s2/shell_extend.c 6d8354c693120a48cfe4798812cd24499be174b2
|
| 58 | +<15 F-cards snipped for brevity>
|
| 59 | +F src/repo.c 2f224cb0e59ccd90ba89c597e40b8e8df unique ID, the same way that
|
| 60 | +a P-card does. A manifest may have multiple P-card parents (the second
|
| 61 | +and subsequent ones denoting merge parents) but B-cards always refer
|
| 62 | +to exactly one parent.
|
| 63 | +
|
| 64 | +What unambiguously distinguishes this as a delta is the existence of
|
| 65 | +the B-card. All deltas have a B-card and no other type of artifact has
|
| 66 | +one. What also, but not unambiguously, distinguishes it as a delta is
|
| 67 | +that it has only 17 F-cards, whereas a baseline manifest in that same
|
| 68 | +repository has (as of this writing) 291 F-cards. In this particular
|
| 69 | +case, the delta manifest is 1363 bytes, compared to 20627 bytes for
|
| 70 | +the next checkin - a baseline manifest. That's a significant saving in
|
| 71 | +F-cards, especially if a repository contains thousands of files. That
|
| 72 | +savings, however, comes with caveats which we'll address below.
|
| 73 | +
|
| 74 | +Trivia regarding the B-card:
|
| 75 | +
|
| 76 | +- The B-card always refers to a baseline manifest, not another delta.
|
| 77 | +- Deltas may not chain with another delta, but any number of deltas
|
| 78 | + may have the same B-card. It is quite common for a series of delta
|
| 79 | + manifest checkins, each of which derives (in the P-card sense) from
|
| 80 | + the one before it, to have the same B-card.
|
| 81 | +
|
| 82 | +A delta manifest is functionally identical to a normal manifest except
|
| 83 | +that it hfds F-cards. Namely, it only
|
| 84 | +records F-cards which have changed at some fhich have changed at some point between this delta
|
| 85 | +and the version represented by the delta's B-card. This recording of
|
| 86 | +F-card *differences* also means that delta manifests, unlike normal
|
| 87 | +manifests, have to explicitly record deleted F-cards. Baseline
|
| 88 | +manifests do not record deletions. f of
|
| 89 | +every file which is part of that checkin. Deltas, however, record the
|
| 90 | +differences between theif version, and thus
|
| 91 | +have to record deletions. They do this by including F-cards which have
|
| 92 | +only a file name and no hash.
|
| 93 | +
|
| 94 | +Iterating over F-cards in a manifest is something several important
|
| 95 | +internal parts of Fossil have to dofst which is intended to take up far less space than
|
| 96 | +a normal checkin manifest, in particular for repositories with
|
| 97 | +many files. We'll see, however, that the space savings, if indeed
|
| 98 | +there are any, come with some caveats.
|
| 99 | +
|
| 100 | +This article assumes that the reader is at least mo#nifest is 1363 bytes, compared to 20627 bytes for
|
| 101 | +the next checkin - a baseline manifest. That's a significant saving in
|
| 102 | +F-cards, especially if a repository contains thousands of files. That
|
| 103 | +savings, however, comes with caveats which we'll address below.
|
| 104 | +
|
| 105 | +Trivia regarding the B-card:
|
| 106 | +
|
| 107 | +- The B-card always refers to a baseline manifest, not another delta.
|
| 108 | +- Deltas may not chain with another delta, but any number of deltas
|
| 109 | + may have the same B-card. It is quite common for a series of delta
|
| 110 | + manifest checkins, each of which derives (in the P-card sense) from
|
| 111 | + the one before it, to have the same B-card.
|
| 112 | +
|
| 113 | +A delta manifest is functionally identical to a normal manifest except
|
| 114 | +that it has a B-card and how it records F-cards. Namely, it only
|
| 115 | +records F-cards which have changed at some point between this delta
|
| 116 | +and the version represented by the delta's B-card. This recording of
|
| 117 | +F-card *differences* also means that delta manifests, unlike normal
|
| 118 | +manifests, have to explicitfs, compared to 20627 bytes for
|
| 119 | +the next checkin - a baseline manifest. That's a significant saving in
|
| 120 | +F-cards, especially if a repository contains thousands of files. That
|
| 121 | +savings, however, comes with caveats which we'll addresfhe B-card:
|
| 122 | +
|
| 123 | +- The B-card always refers to a baseline manifest, not another delta.
|
| 124 | +- Deltas may not chain with another delta, but any number of deltas
|
| 125 | + may have the same B-card. It is quite common for a series of delta
|
| 126 | + manifest checkins, each of which derives (in the P-card sense) from
|
| 127 | + the one before it, to have the same B-cardft, to have the same B-card.
|
| 128 | +
|
| 129 | +A delta manifest is functionally identical to a normal manifest except
|
| 130 | +that it has a B-card and how it records F-cards. Namely, it only
|
| 131 | +records F-cards which have changed at some point between this delta
|
| 132 | +and the version represented by the delta's B-card. This recording of
|
| 133 | +F-card *differences* also means that delta manifests, unlike normal
|
| 134 | +manifests, have to explicitly record deleted F-cafot record deletions. Instead, they include a list of
|
| 135 | +every file which is part of that checkin. Deltas, however, record the
|
| 136 | +differences between their own version and a baseline version, and thus
|
| 137 | +have to record deletions. Tfards which have
|
| 138 | +only a file name and no hash.
|
| 139 | +
|
| 140 | +Iterating over F-cards in a manifest is something several important
|
| 141 | +internal parts of Fossil have to do. Iterating over a baseline
|
| 142 | +manifest, e.g. when performing a checkout, is straightforward: simply
|
| 143 | +walk through the lisf Delta Manifests
|
| 144 | +
|
| 145 | +This article describes "delta manifests," a special case form of
|
| 146 | +checkin manifest which is intended to take up far less space than
|
| 147 | +a normal checkin manifest, in particular for repositories with
|
| 148 | +many files. We'll see, however, that the space savings, if indeed
|
| 149 | +there are any, come with some caveats.
|
| 150 | +
|
| 151 | +This article assumes that the rethe commit process, Fossil
|
| 152 | +examines the size of the delta. If, in Fossil's opinion, the space
|
| 153 | +savings are not significant enough to warrant the delta's own
|
| 154 | +overhead, it will discard the delta and create a new baseline manifest
|
| 155 | +insteadpplied
|
| 156 | +to those manifests, that inks
|
| 157 | +tremendously, often to the point of insignificance.
|
| 158 | +
|
| 159 | +We can observe the Fossil-delta compression savings using a bit of
|
| 160 | +3rd-party code which can extract Fossil-format blobs both with and
|
| 161 | +without applying their deltas:
|
| 162 | +
|
| 163 | +```
|
| 164 | +$ f-acat tip > A # tip version's manifest
|
| 165 | +$ f-acat prev --raw > B # previous manifest in its raw fossil-deltified form
|
| 166 | +$ f-acat prev > C # previous manifest fossil-undelta'd
|
| 167 | +$ ls -la A B C
|
| 168 | +-rw-rw-r-- 1 user user 80252 Mar 12 07:09 A # tido not typicallyMar 12 07:09 A # tip
|
| 169 | +-rw-rw-r
|
| 170 | +for the tip revious: delta'd
|
| 171 | +-rw-rw-r-- 1 user user 80256 Mar 12 07:09 C # previous: undelta'd
|
| 172 | +```
|
| 173 | +
|
| 174 | +For comparison's sake, when looking at a separate repository which
|
| 175 | +uses delta manifests, a delta-compressed delta manifest takes up
|
| 176 | +approximately the same space as a delta-compressed baseline manifest
|
| 177 | +(to within 10 bytes for the test samples).
|
| 178 | +
|
| 179 | +i.e. delta manifests may not save any storage space except for the tip
|
| 180 | +version! (*Surprise!*)
|
| 181 | +
|
| 182 | +In terms of RAM costs, deltas usually cost more memory than baseline
|
| 183 | +manifests. The reason is because traversing a delta requires having
|
| 184 | +not only that delta in memory, but also its baseline version. Delta
|
| 185 | +manifests are seldom used in ways which do not require also loading
|
| 186 | +their baselines. Thus Fossil internally requires two manifest objects
|
| 187 | +for most operations with a delta manifest, whereas a baseline has but
|
| 188 | +one. The difference in RAM cost is directly proportional to the size
|
| 189 | +of the delta manifest.
|
| 190 | +
|
| 191 | +## Manifests as Proof of Code Integrity
|
| 192 | +
|
| 193 | +Delta manifests have at least one more notable caveat, this one
|
| 194 | +arguably more significant than an apparent lack of space savings:fcreate a new baseline manifest
|
| 195 | +insteadpplied
|
| 196 | +to those manifests, that inks
|
| 197 | +tremefmanifests, that inks
|
| 198 | +tremendously, often to the point of insignificance.
|
| 199 | +
|
| 200 | +We can observe the Fossil-delta compression savings using a bit of
|
| 201 | +3rd-party code which can extract Fossil-format blobs both with and
|
| 202 | +without applying their deltas:
|
| 203 | +
|
| 204 | +```
|
| 205 | +$ f-acat tip > A # tip version's manifest
|
| 206 | +$ f-acat prev --raw > B # previous manifest in its raw fossil-deltified form
|
| 207 | +$ f-acat prev > C # previous manifest fossil-undelta'd
|
| 208 | +$ ls -la A B C
|
| 209 | +-rw-rw-r-- 1 user user 80252 Mar 12 07:09 A # tido not typicallyMar 12 07:09 A # tip
|
| 210 | +-rw-rw-r
|
| 211 | +for the tip revious: delta'd
|
| 212 | +-rw-rw-r-- 1 user user 80256 Mar 12 07:09 C # previous: undelta'd
|
| 213 | +```
|
| 214 | +
|
| 215 | +For comparison's sake, when looking at a separate repository which
|
| 216 | +uses delta manifests, a delta-compressed delta manifest takes up
|
| 217 | +approximately the same space as a delta-compressed baseline manifest
|
| 218 | +(to within 10 bytes for the test samples).
|
| 219 | +
|
| 220 | +i.e. delta manifests may not save any storage space except for the tip
|
| 221 | +version! (*Surprise!*)
|
| 222 | +
|
| 223 | +In terms of RAM costs, deltas usually cost more memory than baseline
|
| 224 | +manifests. The reason is because travfrsing a delta requires having
|
| 225 | +not only that delta in memory, but also its baseline version. Delta
|
| 226 | +manifests are seldom used in ways which do not require also loading
|
| 227 | +their baselines. Thus Fossil internally requires two manifest objects
|
| 228 | +for most operations with a delta manifest, whereas a baseline has but
|
| 229 | +one. The difference in RAM cost is directly proportional to the size
|
| 230 | +of the delta manifest.
|
| 231 | +
|
| 232 | +## Manifests as Proof of Code Integrity
|
| 233 | +
|
| 234 | +Delta manifests have at least one more notable caveat, this one
|
| 235 | +arguably more significsqlite3impossi A B C
|
| 236 | +-rw-rw-r-- 1 user user 80252 Mar 12 07:09 A # tido not typicallyMar 12 07:09 A # tip
|
| 237 | +-rw-rw-r
|
| 238 | +for the tip revious: delta'd
|
| 239 | +-rw-rw-r-- 1 user user 80256 Mar 12 07:09 C # previous: undelta'd
|
| 240 | +```
|
| 241 | +
|
| 242 | +For comparison's sake, when looking at a separate repository which
|
| 243 | +uses deltalitern
|
| 244 | +a normal checkin manifest, i# Delt.</div>
|
| 245 | +
|
| 246 | +This article describes "delta manifests," a special-case form of
|
| 247 | +checkin manifest which is intended to take up far less space than
|
| 248 | +a normal checkin manifest, in particular for repositories with
|
| 249 | +many files. We'll see, however, that the space savings, if indeed
|
| 250 | +there are any, come with some caveats.
|
| 251 | +
|
| 252 | +This article assumes that the reader is at least moderately familiar
|
| 253 | +with Fossil's [artifact file format](./fileformat.wiki), in particular
|
| 254 | +the structure of checkin manifests, and it won't maks much sense to
|
| 255 | +readers unfamiliar with that topic.
|
| 256 | +
|
| 257 | +# Background and Motivation of Delta Manifests
|
| 258 | +
|
| 259 | +A checkin manifest includes a list of every file in that checkin. A
|
| 260 | +moderately-sized project can easily have a thousand files, and every
|
| 261 | +checkin manifest will include those thousand files. As of this writing
|
| 262 | +Fossil's own checkins contain 989 files and the manifests are 80kb
|
| 263 | +each. |