Junio C Hamano | 944ce25 | 2018-05-30 22:25:26 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 3 | "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 5 | <head> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 6 | <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
Junio C Hamano | a85030a | 2022-07-27 16:48:21 | [diff] [blame] | 7 | <meta name="generator" content="AsciiDoc 10.2.0" /> |
Junio C Hamano | bc8d478 | 2014-01-13 23:35:50 | [diff] [blame] | 8 | <title>Concerning Git’s Packing Heuristics</title> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 9 | <style type="text/css"> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 10 | /* Shared CSS for AsciiDoc xhtml11 and html5 backends */ |
| 11 | |
| 12 | /* Default font. */ |
| 13 | body { |
| 14 | font-family: Georgia,serif; |
| 15 | } |
| 16 | |
| 17 | /* Title font. */ |
| 18 | h1, h2, h3, h4, h5, h6, |
| 19 | div.title, caption.title, |
| 20 | thead, p.table.header, |
| 21 | #toctitle, |
| 22 | #author, #revnumber, #revdate, #revremark, |
| 23 | #footer { |
| 24 | font-family: Arial,Helvetica,sans-serif; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | body { |
| 28 | margin: 1em 5% 1em 5%; |
| 29 | } |
| 30 | |
| 31 | a { |
| 32 | color: blue; |
| 33 | text-decoration: underline; |
| 34 | } |
| 35 | a:visited { |
| 36 | color: fuchsia; |
| 37 | } |
| 38 | |
| 39 | em { |
| 40 | font-style: italic; |
| 41 | color: navy; |
| 42 | } |
| 43 | |
| 44 | strong { |
| 45 | font-weight: bold; |
| 46 | color: #083194; |
| 47 | } |
| 48 | |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 49 | h1, h2, h3, h4, h5, h6 { |
| 50 | color: #527bbd; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 51 | margin-top: 1.2em; |
| 52 | margin-bottom: 0.5em; |
| 53 | line-height: 1.3; |
| 54 | } |
| 55 | |
| 56 | h1, h2, h3 { |
| 57 | border-bottom: 2px solid silver; |
| 58 | } |
| 59 | h2 { |
| 60 | padding-top: 0.5em; |
| 61 | } |
| 62 | h3 { |
| 63 | float: left; |
| 64 | } |
| 65 | h3 + * { |
| 66 | clear: left; |
| 67 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 68 | h5 { |
| 69 | font-size: 1.0em; |
| 70 | } |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 71 | |
| 72 | div.sectionbody { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 73 | margin-left: 0; |
| 74 | } |
| 75 | |
| 76 | hr { |
| 77 | border: 1px solid silver; |
| 78 | } |
| 79 | |
| 80 | p { |
| 81 | margin-top: 0.5em; |
| 82 | margin-bottom: 0.5em; |
| 83 | } |
| 84 | |
| 85 | ul, ol, li > p { |
| 86 | margin-top: 0; |
| 87 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 88 | ul > li { color: #aaa; } |
| 89 | ul > li > * { color: black; } |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 90 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 91 | .monospaced, code, pre { |
| 92 | font-family: "Courier New", Courier, monospace; |
| 93 | font-size: inherit; |
| 94 | color: navy; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 95 | padding: 0; |
| 96 | margin: 0; |
| 97 | } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 98 | pre { |
| 99 | white-space: pre-wrap; |
| 100 | } |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 101 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 102 | #author { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 103 | color: #527bbd; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 104 | font-weight: bold; |
| 105 | font-size: 1.1em; |
| 106 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 107 | #email { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 108 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 109 | #revnumber, #revdate, #revremark { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 110 | } |
| 111 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 112 | #footer { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 113 | font-size: small; |
| 114 | border-top: 2px solid silver; |
| 115 | padding-top: 0.5em; |
| 116 | margin-top: 4.0em; |
| 117 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 118 | #footer-text { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 119 | float: left; |
| 120 | padding-bottom: 0.5em; |
| 121 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 122 | #footer-badges { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 123 | float: right; |
| 124 | padding-bottom: 0.5em; |
| 125 | } |
| 126 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 127 | #preamble { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 128 | margin-top: 1.5em; |
| 129 | margin-bottom: 1.5em; |
| 130 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 131 | div.imageblock, div.exampleblock, div.verseblock, |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 132 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 133 | div.admonitionblock { |
| 134 | margin-top: 1.0em; |
| 135 | margin-bottom: 1.5em; |
| 136 | } |
| 137 | div.admonitionblock { |
| 138 | margin-top: 2.0em; |
| 139 | margin-bottom: 2.0em; |
| 140 | margin-right: 10%; |
| 141 | color: #606060; |
| 142 | } |
| 143 | |
| 144 | div.content { /* Block element content. */ |
| 145 | padding: 0; |
| 146 | } |
| 147 | |
| 148 | /* Block element titles. */ |
| 149 | div.title, caption.title { |
| 150 | color: #527bbd; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 151 | font-weight: bold; |
| 152 | text-align: left; |
| 153 | margin-top: 1.0em; |
| 154 | margin-bottom: 0.5em; |
| 155 | } |
| 156 | div.title + * { |
| 157 | margin-top: 0; |
| 158 | } |
| 159 | |
| 160 | td div.title:first-child { |
| 161 | margin-top: 0.0em; |
| 162 | } |
| 163 | div.content div.title:first-child { |
| 164 | margin-top: 0.0em; |
| 165 | } |
| 166 | div.content + div.title { |
| 167 | margin-top: 0.0em; |
| 168 | } |
| 169 | |
| 170 | div.sidebarblock > div.content { |
| 171 | background: #ffffee; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 172 | border: 1px solid #dddddd; |
| 173 | border-left: 4px solid #f0f0f0; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 174 | padding: 0.5em; |
| 175 | } |
| 176 | |
| 177 | div.listingblock > div.content { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 178 | border: 1px solid #dddddd; |
| 179 | border-left: 5px solid #f0f0f0; |
| 180 | background: #f8f8f8; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 181 | padding: 0.5em; |
| 182 | } |
| 183 | |
| 184 | div.quoteblock, div.verseblock { |
| 185 | padding-left: 1.0em; |
| 186 | margin-left: 1.0em; |
| 187 | margin-right: 10%; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 188 | border-left: 5px solid #f0f0f0; |
| 189 | color: #888; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | div.quoteblock > div.attribution { |
| 193 | padding-top: 0.5em; |
| 194 | text-align: right; |
| 195 | } |
| 196 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 197 | div.verseblock > pre.content { |
| 198 | font-family: inherit; |
| 199 | font-size: inherit; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 200 | } |
| 201 | div.verseblock > div.attribution { |
| 202 | padding-top: 0.75em; |
| 203 | text-align: left; |
| 204 | } |
| 205 | /* DEPRECATED: Pre version 8.2.7 verse style literal block. */ |
| 206 | div.verseblock + div.attribution { |
| 207 | text-align: left; |
| 208 | } |
| 209 | |
| 210 | div.admonitionblock .icon { |
| 211 | vertical-align: top; |
| 212 | font-size: 1.1em; |
| 213 | font-weight: bold; |
| 214 | text-decoration: underline; |
| 215 | color: #527bbd; |
| 216 | padding-right: 0.5em; |
| 217 | } |
| 218 | div.admonitionblock td.content { |
| 219 | padding-left: 0.5em; |
| 220 | border-left: 3px solid #dddddd; |
| 221 | } |
| 222 | |
| 223 | div.exampleblock > div.content { |
| 224 | border-left: 3px solid #dddddd; |
| 225 | padding-left: 0.5em; |
| 226 | } |
| 227 | |
| 228 | div.imageblock div.content { padding-left: 0; } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 229 | span.image img { border-style: none; vertical-align: text-bottom; } |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 230 | a.image:visited { color: white; } |
| 231 | |
| 232 | dl { |
| 233 | margin-top: 0.8em; |
| 234 | margin-bottom: 0.8em; |
| 235 | } |
| 236 | dt { |
| 237 | margin-top: 0.5em; |
| 238 | margin-bottom: 0; |
| 239 | font-style: normal; |
| 240 | color: navy; |
| 241 | } |
| 242 | dd > *:first-child { |
| 243 | margin-top: 0.1em; |
| 244 | } |
| 245 | |
| 246 | ul, ol { |
| 247 | list-style-position: outside; |
| 248 | } |
| 249 | ol.arabic { |
| 250 | list-style-type: decimal; |
| 251 | } |
| 252 | ol.loweralpha { |
| 253 | list-style-type: lower-alpha; |
| 254 | } |
| 255 | ol.upperalpha { |
| 256 | list-style-type: upper-alpha; |
| 257 | } |
| 258 | ol.lowerroman { |
| 259 | list-style-type: lower-roman; |
| 260 | } |
| 261 | ol.upperroman { |
| 262 | list-style-type: upper-roman; |
| 263 | } |
| 264 | |
| 265 | div.compact ul, div.compact ol, |
| 266 | div.compact p, div.compact p, |
| 267 | div.compact div, div.compact div { |
| 268 | margin-top: 0.1em; |
| 269 | margin-bottom: 0.1em; |
| 270 | } |
| 271 | |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 272 | tfoot { |
| 273 | font-weight: bold; |
| 274 | } |
| 275 | td > div.verse { |
| 276 | white-space: pre; |
| 277 | } |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 278 | |
| 279 | div.hdlist { |
| 280 | margin-top: 0.8em; |
| 281 | margin-bottom: 0.8em; |
| 282 | } |
| 283 | div.hdlist tr { |
| 284 | padding-bottom: 15px; |
| 285 | } |
| 286 | dt.hdlist1.strong, td.hdlist1.strong { |
| 287 | font-weight: bold; |
| 288 | } |
| 289 | td.hdlist1 { |
| 290 | vertical-align: top; |
| 291 | font-style: normal; |
| 292 | padding-right: 0.8em; |
| 293 | color: navy; |
| 294 | } |
| 295 | td.hdlist2 { |
| 296 | vertical-align: top; |
| 297 | } |
| 298 | div.hdlist.compact tr { |
| 299 | margin: 0; |
| 300 | padding-bottom: 0; |
| 301 | } |
| 302 | |
| 303 | .comment { |
| 304 | background: yellow; |
| 305 | } |
| 306 | |
| 307 | .footnote, .footnoteref { |
| 308 | font-size: 0.8em; |
| 309 | } |
| 310 | |
| 311 | span.footnote, span.footnoteref { |
| 312 | vertical-align: super; |
| 313 | } |
| 314 | |
| 315 | #footnotes { |
| 316 | margin: 20px 0 20px 0; |
| 317 | padding: 7px 0 0 0; |
| 318 | } |
| 319 | |
| 320 | #footnotes div.footnote { |
| 321 | margin: 0 0 5px 0; |
| 322 | } |
| 323 | |
| 324 | #footnotes hr { |
| 325 | border: none; |
| 326 | border-top: 1px solid silver; |
| 327 | height: 1px; |
| 328 | text-align: left; |
| 329 | margin-left: 0; |
| 330 | width: 20%; |
| 331 | min-width: 100px; |
| 332 | } |
| 333 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 334 | div.colist td { |
| 335 | padding-right: 0.5em; |
| 336 | padding-bottom: 0.3em; |
| 337 | vertical-align: top; |
| 338 | } |
| 339 | div.colist td img { |
| 340 | margin-top: 0.3em; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 341 | } |
| 342 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 343 | @media print { |
| 344 | #footer-badges { display: none; } |
| 345 | } |
| 346 | |
| 347 | #toc { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 348 | margin-bottom: 2.5em; |
| 349 | } |
| 350 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 351 | #toctitle { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 352 | color: #527bbd; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 353 | font-size: 1.1em; |
| 354 | font-weight: bold; |
| 355 | margin-top: 1.0em; |
| 356 | margin-bottom: 0.1em; |
| 357 | } |
| 358 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 359 | div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 360 | margin-top: 0; |
| 361 | margin-bottom: 0; |
| 362 | } |
| 363 | div.toclevel2 { |
| 364 | margin-left: 2em; |
| 365 | font-size: 0.9em; |
| 366 | } |
| 367 | div.toclevel3 { |
| 368 | margin-left: 4em; |
| 369 | font-size: 0.9em; |
| 370 | } |
| 371 | div.toclevel4 { |
| 372 | margin-left: 6em; |
| 373 | font-size: 0.9em; |
| 374 | } |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 375 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 376 | span.aqua { color: aqua; } |
| 377 | span.black { color: black; } |
| 378 | span.blue { color: blue; } |
| 379 | span.fuchsia { color: fuchsia; } |
| 380 | span.gray { color: gray; } |
| 381 | span.green { color: green; } |
| 382 | span.lime { color: lime; } |
| 383 | span.maroon { color: maroon; } |
| 384 | span.navy { color: navy; } |
| 385 | span.olive { color: olive; } |
| 386 | span.purple { color: purple; } |
| 387 | span.red { color: red; } |
| 388 | span.silver { color: silver; } |
| 389 | span.teal { color: teal; } |
| 390 | span.white { color: white; } |
| 391 | span.yellow { color: yellow; } |
| 392 | |
| 393 | span.aqua-background { background: aqua; } |
| 394 | span.black-background { background: black; } |
| 395 | span.blue-background { background: blue; } |
| 396 | span.fuchsia-background { background: fuchsia; } |
| 397 | span.gray-background { background: gray; } |
| 398 | span.green-background { background: green; } |
| 399 | span.lime-background { background: lime; } |
| 400 | span.maroon-background { background: maroon; } |
| 401 | span.navy-background { background: navy; } |
| 402 | span.olive-background { background: olive; } |
| 403 | span.purple-background { background: purple; } |
| 404 | span.red-background { background: red; } |
| 405 | span.silver-background { background: silver; } |
| 406 | span.teal-background { background: teal; } |
| 407 | span.white-background { background: white; } |
| 408 | span.yellow-background { background: yellow; } |
| 409 | |
| 410 | span.big { font-size: 2em; } |
| 411 | span.small { font-size: 0.6em; } |
| 412 | |
| 413 | span.underline { text-decoration: underline; } |
| 414 | span.overline { text-decoration: overline; } |
| 415 | span.line-through { text-decoration: line-through; } |
| 416 | |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 417 | div.unbreakable { page-break-inside: avoid; } |
| 418 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 419 | |
| 420 | /* |
| 421 | * xhtml11 specific |
| 422 | * |
| 423 | * */ |
| 424 | |
| 425 | div.tableblock { |
| 426 | margin-top: 1.0em; |
| 427 | margin-bottom: 1.5em; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 428 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 429 | div.tableblock > table { |
| 430 | border: 3px solid #527bbd; |
| 431 | } |
| 432 | thead, p.table.header { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 433 | font-weight: bold; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 434 | color: #527bbd; |
| 435 | } |
| 436 | p.table { |
| 437 | margin-top: 0; |
| 438 | } |
Junio C Hamano | 725b0da | 2020-01-22 22:02:40 | [diff] [blame] | 439 | /* Because the table frame attribute is overridden by CSS in most browsers. */ |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 440 | div.tableblock > table[frame="void"] { |
| 441 | border-style: none; |
| 442 | } |
| 443 | div.tableblock > table[frame="hsides"] { |
| 444 | border-left-style: none; |
| 445 | border-right-style: none; |
| 446 | } |
| 447 | div.tableblock > table[frame="vsides"] { |
| 448 | border-top-style: none; |
| 449 | border-bottom-style: none; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 450 | } |
| 451 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 452 | |
| 453 | /* |
| 454 | * html5 specific |
| 455 | * |
| 456 | * */ |
| 457 | |
| 458 | table.tableblock { |
| 459 | margin-top: 1.0em; |
| 460 | margin-bottom: 1.5em; |
| 461 | } |
| 462 | thead, p.tableblock.header { |
| 463 | font-weight: bold; |
| 464 | color: #527bbd; |
| 465 | } |
| 466 | p.tableblock { |
| 467 | margin-top: 0; |
| 468 | } |
| 469 | table.tableblock { |
| 470 | border-width: 3px; |
| 471 | border-spacing: 0px; |
| 472 | border-style: solid; |
| 473 | border-color: #527bbd; |
| 474 | border-collapse: collapse; |
| 475 | } |
| 476 | th.tableblock, td.tableblock { |
| 477 | border-width: 1px; |
| 478 | padding: 4px; |
| 479 | border-style: solid; |
| 480 | border-color: #527bbd; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 481 | } |
| 482 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 483 | table.tableblock.frame-topbot { |
| 484 | border-left-style: hidden; |
| 485 | border-right-style: hidden; |
| 486 | } |
| 487 | table.tableblock.frame-sides { |
| 488 | border-top-style: hidden; |
| 489 | border-bottom-style: hidden; |
| 490 | } |
| 491 | table.tableblock.frame-none { |
| 492 | border-style: hidden; |
| 493 | } |
| 494 | |
| 495 | th.tableblock.halign-left, td.tableblock.halign-left { |
| 496 | text-align: left; |
| 497 | } |
| 498 | th.tableblock.halign-center, td.tableblock.halign-center { |
| 499 | text-align: center; |
| 500 | } |
| 501 | th.tableblock.halign-right, td.tableblock.halign-right { |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 502 | text-align: right; |
| 503 | } |
| 504 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 505 | th.tableblock.valign-top, td.tableblock.valign-top { |
| 506 | vertical-align: top; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 507 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 508 | th.tableblock.valign-middle, td.tableblock.valign-middle { |
| 509 | vertical-align: middle; |
| 510 | } |
| 511 | th.tableblock.valign-bottom, td.tableblock.valign-bottom { |
| 512 | vertical-align: bottom; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 513 | } |
| 514 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 515 | |
| 516 | /* |
| 517 | * manpage specific |
| 518 | * |
| 519 | * */ |
| 520 | |
| 521 | body.manpage h1 { |
| 522 | padding-top: 0.5em; |
| 523 | padding-bottom: 0.5em; |
| 524 | border-top: 2px solid silver; |
| 525 | border-bottom: 2px solid silver; |
| 526 | } |
| 527 | body.manpage h2 { |
| 528 | border-style: none; |
| 529 | } |
| 530 | body.manpage div.sectionbody { |
| 531 | margin-left: 3em; |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 532 | } |
| 533 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 534 | @media print { |
| 535 | body.manpage div#toc { display: none; } |
| 536 | } |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 537 | |
| 538 | |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 539 | </style> |
| 540 | <script type="text/javascript"> |
| 541 | /*<![CDATA[*/ |
Junio C Hamano | 2b15318 | 2021-12-15 21:00:31 | [diff] [blame] | 542 | var asciidoc = { // Namespace. |
| 543 | |
| 544 | ///////////////////////////////////////////////////////////////////// |
| 545 | // Table Of Contents generator |
| 546 | ///////////////////////////////////////////////////////////////////// |
| 547 | |
| 548 | /* Author: Mihai Bazon, September 2002 |
| 549 | * http://students.infoiasi.ro/~mishoo |
| 550 | * |
| 551 | * Table Of Content generator |
| 552 | * Version: 0.4 |
| 553 | * |
| 554 | * Feel free to use this script under the terms of the GNU General Public |
| 555 | * License, as long as you do not remove or alter this notice. |
| 556 | */ |
| 557 | |
| 558 | /* modified by Troy D. Hanson, September 2006. License: GPL */ |
| 559 | /* modified by Stuart Rackham, 2006, 2009. License: GPL */ |
| 560 | |
| 561 | // toclevels = 1..4. |
| 562 | toc: function (toclevels) { |
| 563 | |
| 564 | function getText(el) { |
| 565 | var text = ""; |
| 566 | for (var i = el.firstChild; i != null; i = i.nextSibling) { |
| 567 | if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants. |
| 568 | text += i.data; |
| 569 | else if (i.firstChild != null) |
| 570 | text += getText(i); |
| 571 | } |
| 572 | return text; |
| 573 | } |
| 574 | |
| 575 | function TocEntry(el, text, toclevel) { |
| 576 | this.element = el; |
| 577 | this.text = text; |
| 578 | this.toclevel = toclevel; |
| 579 | } |
| 580 | |
| 581 | function tocEntries(el, toclevels) { |
| 582 | var result = new Array; |
| 583 | var re = new RegExp('[hH]([1-'+(toclevels+1)+'])'); |
| 584 | // Function that scans the DOM tree for header elements (the DOM2 |
| 585 | // nodeIterator API would be a better technique but not supported by all |
| 586 | // browsers). |
| 587 | var iterate = function (el) { |
| 588 | for (var i = el.firstChild; i != null; i = i.nextSibling) { |
| 589 | if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { |
| 590 | var mo = re.exec(i.tagName); |
| 591 | if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { |
| 592 | result[result.length] = new TocEntry(i, getText(i), mo[1]-1); |
| 593 | } |
| 594 | iterate(i); |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | iterate(el); |
| 599 | return result; |
| 600 | } |
| 601 | |
| 602 | var toc = document.getElementById("toc"); |
| 603 | if (!toc) { |
| 604 | return; |
| 605 | } |
| 606 | |
| 607 | // Delete existing TOC entries in case we're reloading the TOC. |
| 608 | var tocEntriesToRemove = []; |
| 609 | var i; |
| 610 | for (i = 0; i < toc.childNodes.length; i++) { |
| 611 | var entry = toc.childNodes[i]; |
| 612 | if (entry.nodeName.toLowerCase() == 'div' |
| 613 | && entry.getAttribute("class") |
| 614 | && entry.getAttribute("class").match(/^toclevel/)) |
| 615 | tocEntriesToRemove.push(entry); |
| 616 | } |
| 617 | for (i = 0; i < tocEntriesToRemove.length; i++) { |
| 618 | toc.removeChild(tocEntriesToRemove[i]); |
| 619 | } |
| 620 | |
| 621 | // Rebuild TOC entries. |
| 622 | var entries = tocEntries(document.getElementById("content"), toclevels); |
| 623 | for (var i = 0; i < entries.length; ++i) { |
| 624 | var entry = entries[i]; |
| 625 | if (entry.element.id == "") |
| 626 | entry.element.id = "_toc_" + i; |
| 627 | var a = document.createElement("a"); |
| 628 | a.href = "#" + entry.element.id; |
| 629 | a.appendChild(document.createTextNode(entry.text)); |
| 630 | var div = document.createElement("div"); |
| 631 | div.appendChild(a); |
| 632 | div.className = "toclevel" + entry.toclevel; |
| 633 | toc.appendChild(div); |
| 634 | } |
| 635 | if (entries.length == 0) |
| 636 | toc.parentNode.removeChild(toc); |
| 637 | }, |
| 638 | |
| 639 | |
| 640 | ///////////////////////////////////////////////////////////////////// |
| 641 | // Footnotes generator |
| 642 | ///////////////////////////////////////////////////////////////////// |
| 643 | |
| 644 | /* Based on footnote generation code from: |
| 645 | * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html |
| 646 | */ |
| 647 | |
| 648 | footnotes: function () { |
| 649 | // Delete existing footnote entries in case we're reloading the footnodes. |
| 650 | var i; |
| 651 | var noteholder = document.getElementById("footnotes"); |
| 652 | if (!noteholder) { |
| 653 | return; |
| 654 | } |
| 655 | var entriesToRemove = []; |
| 656 | for (i = 0; i < noteholder.childNodes.length; i++) { |
| 657 | var entry = noteholder.childNodes[i]; |
| 658 | if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") |
| 659 | entriesToRemove.push(entry); |
| 660 | } |
| 661 | for (i = 0; i < entriesToRemove.length; i++) { |
| 662 | noteholder.removeChild(entriesToRemove[i]); |
| 663 | } |
| 664 | |
| 665 | // Rebuild footnote entries. |
| 666 | var cont = document.getElementById("content"); |
| 667 | var spans = cont.getElementsByTagName("span"); |
| 668 | var refs = {}; |
| 669 | var n = 0; |
| 670 | for (i=0; i<spans.length; i++) { |
| 671 | if (spans[i].className == "footnote") { |
| 672 | n++; |
| 673 | var note = spans[i].getAttribute("data-note"); |
| 674 | if (!note) { |
| 675 | // Use [\s\S] in place of . so multi-line matches work. |
| 676 | // Because JavaScript has no s (dotall) regex flag. |
| 677 | note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1]; |
| 678 | spans[i].innerHTML = |
| 679 | "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n + |
| 680 | "' title='View footnote' class='footnote'>" + n + "</a>]"; |
| 681 | spans[i].setAttribute("data-note", note); |
| 682 | } |
| 683 | noteholder.innerHTML += |
| 684 | "<div class='footnote' id='_footnote_" + n + "'>" + |
| 685 | "<a href='#_footnoteref_" + n + "' title='Return to text'>" + |
| 686 | n + "</a>. " + note + "</div>"; |
| 687 | var id =spans[i].getAttribute("id"); |
| 688 | if (id != null) refs["#"+id] = n; |
| 689 | } |
| 690 | } |
| 691 | if (n == 0) |
| 692 | noteholder.parentNode.removeChild(noteholder); |
| 693 | else { |
| 694 | // Process footnoterefs. |
| 695 | for (i=0; i<spans.length; i++) { |
| 696 | if (spans[i].className == "footnoteref") { |
| 697 | var href = spans[i].getElementsByTagName("a")[0].getAttribute("href"); |
| 698 | href = href.match(/#.*/)[0]; // Because IE return full URL. |
| 699 | n = refs[href]; |
| 700 | spans[i].innerHTML = |
| 701 | "[<a href='#_footnote_" + n + |
| 702 | "' title='View footnote' class='footnote'>" + n + "</a>]"; |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | }, |
| 707 | |
| 708 | install: function(toclevels) { |
| 709 | var timerId; |
| 710 | |
| 711 | function reinstall() { |
| 712 | asciidoc.footnotes(); |
| 713 | if (toclevels) { |
| 714 | asciidoc.toc(toclevels); |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | function reinstallAndRemoveTimer() { |
| 719 | clearInterval(timerId); |
| 720 | reinstall(); |
| 721 | } |
| 722 | |
| 723 | timerId = setInterval(reinstall, 500); |
| 724 | if (document.addEventListener) |
| 725 | document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); |
| 726 | else |
| 727 | window.onload = reinstallAndRemoveTimer; |
| 728 | } |
| 729 | |
| 730 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 731 | asciidoc.install(); |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 732 | /*]]>*/ |
| 733 | </script> |
| 734 | </head> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 735 | <body class="article"> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 736 | <div id="header"> |
Junio C Hamano | bc8d478 | 2014-01-13 23:35:50 | [diff] [blame] | 737 | <h1>Concerning Git’s Packing Heuristics</h1> |
Junio C Hamano | c1f1c70 | 2023-11-13 03:54:46 | [diff] [blame^] | 738 | <span id="revdate">2023-11-11</span> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 739 | </div> |
| 740 | <div id="content"> |
Junio C Hamano | bc8d478 | 2014-01-13 23:35:50 | [diff] [blame] | 741 | <div id="preamble"> |
| 742 | <div class="sectionbody"> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 743 | <div class="literalblock"> |
| 744 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 745 | <pre><code>Oh, here's a really stupid question:</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 746 | </div></div> |
| 747 | <div class="literalblock"> |
| 748 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 749 | <pre><code> Where do I go |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 750 | to learn the details |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 751 | of Git's packing heuristics?</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 752 | </div></div> |
| 753 | <div class="paragraph"><p>Be careful what you ask!</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 754 | <div class="paragraph"><p>Followers of the Git, please open the Git IRC Log and turn to |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 755 | February 10, 2006.</p></div> |
| 756 | <div class="paragraph"><p>It’s a rare occasion, and we are joined by the King Git Himself, |
| 757 | Linus Torvalds (linus). Nathaniel Smith, (njs`), has the floor |
| 758 | and seeks enlightenment. Others are present, but silent.</p></div> |
| 759 | <div class="paragraph"><p>Let’s listen in!</p></div> |
| 760 | <div class="literalblock"> |
| 761 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 762 | <pre><code><njs`> Oh, here's a really stupid question -- where do I go to |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 763 | learn the details of Git's packing heuristics? google avails |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 764 | me not, reading the source didn't help a lot, and wading |
| 765 | through the whole mailing list seems less efficient than any |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 766 | of that.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 767 | </div></div> |
| 768 | <div class="paragraph"><p>It is a bold start! A plea for help combined with a simultaneous |
| 769 | tri-part attack on some of the tried and true mainstays in the quest |
| 770 | for enlightenment. Brash accusations of google being useless. Hubris! |
| 771 | Maligning the source. Heresy! Disdain for the mailing list archives. |
| 772 | Woe.</p></div> |
| 773 | <div class="literalblock"> |
| 774 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 775 | <pre><code><pasky> yes, the packing-related delta stuff is somewhat |
| 776 | mysterious even for me ;)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 777 | </div></div> |
| 778 | <div class="paragraph"><p>Ah! Modesty after all.</p></div> |
| 779 | <div class="literalblock"> |
| 780 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 781 | <pre><code><linus> njs, I don't think the docs exist. That's something where |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 782 | I don't think anybody else than me even really got involved. |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 783 | Most of the rest of Git others have been busy with (especially |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 784 | Junio), but packing nobody touched after I did it.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 785 | </div></div> |
| 786 | <div class="paragraph"><p>It’s cryptic, yet vague. Linus in style for sure. Wise men |
| 787 | interpret this as an apology. A few argue it is merely a |
| 788 | statement of fact.</p></div> |
| 789 | <div class="literalblock"> |
| 790 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 791 | <pre><code><njs`> I guess the next step is "read the source again", but I |
| 792 | have to build up a certain level of gumption first :-)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 793 | </div></div> |
| 794 | <div class="paragraph"><p>Indeed! On both points.</p></div> |
| 795 | <div class="literalblock"> |
| 796 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 797 | <pre><code><linus> The packing heuristic is actually really really simple.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 798 | </div></div> |
| 799 | <div class="paragraph"><p>Bait…</p></div> |
| 800 | <div class="literalblock"> |
| 801 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 802 | <pre><code><linus> But strange.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 803 | </div></div> |
| 804 | <div class="paragraph"><p>And switch. That ought to do it!</p></div> |
| 805 | <div class="literalblock"> |
| 806 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 807 | <pre><code><linus> Remember: Git really doesn't follow files. So what it does is |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 808 | - generate a list of all objects |
| 809 | - sort the list according to magic heuristics |
| 810 | - walk the list, using a sliding window, seeing if an object |
| 811 | can be diffed against another object in the window |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 812 | - write out the list in recency order</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 813 | </div></div> |
| 814 | <div class="paragraph"><p>The traditional understatement:</p></div> |
| 815 | <div class="literalblock"> |
| 816 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 817 | <pre><code><njs`> I suspect that what I'm missing is the precise definition of |
| 818 | the word "magic"</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 819 | </div></div> |
| 820 | <div class="paragraph"><p>The traditional insight:</p></div> |
| 821 | <div class="literalblock"> |
| 822 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 823 | <pre><code><pasky> yes</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 824 | </div></div> |
| 825 | <div class="paragraph"><p>And Babel-like confusion flowed.</p></div> |
| 826 | <div class="literalblock"> |
| 827 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 828 | <pre><code><njs`> oh, hmm, and I'm not sure what this sliding window means either</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 829 | </div></div> |
| 830 | <div class="literalblock"> |
| 831 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 832 | <pre><code><pasky> iirc, it appeared to me to be just the sha1 of the object |
| 833 | when reading the code casually ...</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 834 | </div></div> |
| 835 | <div class="olist lowerroman"><ol class="lowerroman"> |
| 836 | <li> |
| 837 | <p> |
| 838 | which simply doesn’t sound as a very good heuristics, though ;) |
| 839 | </p> |
| 840 | <div class="literalblock"> |
| 841 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 842 | <pre><code><njs`> .....and recency order. okay, I think it's clear I didn't |
| 843 | even realize how much I wasn't realizing :-)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 844 | </div></div> |
| 845 | </li> |
| 846 | </ol></div> |
| 847 | <div class="paragraph"><p>Ah, grasshopper! And thus the enlightenment begins anew.</p></div> |
| 848 | <div class="literalblock"> |
| 849 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 850 | <pre><code><linus> The "magic" is actually in theory totally arbitrary. |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 851 | ANY order will give you a working pack, but no, it's not |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 852 | ordered by SHA-1.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 853 | </div></div> |
| 854 | <div class="literalblock"> |
| 855 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 856 | <pre><code>Before talking about the ordering for the sliding delta |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 857 | window, let's talk about the recency order. That's more |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 858 | important in one way.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 859 | </div></div> |
| 860 | <div class="literalblock"> |
| 861 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 862 | <pre><code><njs`> Right, but if all you want is a working way to pack things |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 863 | together, you could just use cat and save yourself some |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 864 | trouble...</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 865 | </div></div> |
| 866 | <div class="paragraph"><p>Waaait for it….</p></div> |
| 867 | <div class="literalblock"> |
| 868 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 869 | <pre><code><linus> The recency ordering (which is basically: put objects |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 870 | _physically_ into the pack in the order that they are |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 871 | "reachable" from the head) is important.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 872 | </div></div> |
| 873 | <div class="literalblock"> |
| 874 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 875 | <pre><code><njs`> okay</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 876 | </div></div> |
| 877 | <div class="literalblock"> |
| 878 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 879 | <pre><code><linus> It's important because that's the thing that gives packs |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 880 | good locality. It keeps the objects close to the head (whether |
| 881 | they are old or new, but they are _reachable_ from the head) |
| 882 | at the head of the pack. So packs actually have absolutely |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 883 | _wonderful_ IO patterns.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 884 | </div></div> |
| 885 | <div class="paragraph"><p>Read that again, because it is important.</p></div> |
| 886 | <div class="literalblock"> |
| 887 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 888 | <pre><code><linus> But recency ordering is totally useless for deciding how |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 889 | to actually generate the deltas, so the delta ordering is |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 890 | something else.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 891 | </div></div> |
| 892 | <div class="literalblock"> |
| 893 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 894 | <pre><code>The delta ordering is (wait for it): |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 895 | - first sort by the "basename" of the object, as defined by |
| 896 | the name the object was _first_ reached through when |
| 897 | generating the object list |
| 898 | - within the same basename, sort by size of the object |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 899 | - but always sort different types separately (commits first).</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 900 | </div></div> |
| 901 | <div class="literalblock"> |
| 902 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 903 | <pre><code>That's not exactly it, but it's very close.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 904 | </div></div> |
| 905 | <div class="literalblock"> |
| 906 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 907 | <pre><code><njs`> The "_first_ reached" thing is not too important, just you |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 908 | need some way to break ties since the same objects may be |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 909 | reachable many ways, yes?</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 910 | </div></div> |
| 911 | <div class="paragraph"><p>And as if to clarify:</p></div> |
| 912 | <div class="literalblock"> |
| 913 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 914 | <pre><code><linus> The point is that it's all really just any random |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 915 | heuristic, and the ordering is totally unimportant for |
| 916 | correctness, but it helps a lot if the heuristic gives |
| 917 | "clumping" for things that are likely to delta well against |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 918 | each other.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 919 | </div></div> |
| 920 | <div class="paragraph"><p>It is an important point, so secretly, I did my own research and have |
| 921 | included my results below. To be fair, it has changed some over time. |
| 922 | And through the magic of Revisionistic History, I draw upon this entry |
| 923 | from The Git IRC Logs on my father’s birthday, March 1:</p></div> |
| 924 | <div class="literalblock"> |
| 925 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 926 | <pre><code><gitster> The quote from the above linus should be rewritten a |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 927 | bit (wait for it): |
| 928 | - first sort by type. Different objects never delta with |
| 929 | each other. |
| 930 | - then sort by filename/dirname. hash of the basename |
| 931 | occupies the top BITS_PER_INT-DIR_BITS bits, and bottom |
| 932 | DIR_BITS are for the hash of leading path elements. |
| 933 | - then if we are doing "thin" pack, the objects we are _not_ |
| 934 | going to pack but we know about are sorted earlier than |
| 935 | other objects. |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 936 | - and finally sort by size, larger to smaller.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 937 | </div></div> |
| 938 | <div class="paragraph"><p>In one swell-foop, clarification and obscurification! Nonetheless, |
| 939 | authoritative. Cryptic, yet concise. It even solicits notions of |
| 940 | quotes from The Source Code. Clearly, more study is needed.</p></div> |
| 941 | <div class="literalblock"> |
| 942 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 943 | <pre><code><gitster> That's the sort order. What this means is: |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 944 | - we do not delta different object types. |
| 945 | - we prefer to delta the objects with the same full path, but |
| 946 | allow files with the same name from different directories. |
| 947 | - we always prefer to delta against objects we are not going |
| 948 | to send, if there are some. |
| 949 | - we prefer to delta against larger objects, so that we have |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 950 | lots of removals.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 951 | </div></div> |
| 952 | <div class="literalblock"> |
| 953 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 954 | <pre><code>The penultimate rule is for "thin" packs. It is used when |
| 955 | the other side is known to have such objects.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 956 | </div></div> |
| 957 | <div class="paragraph"><p>There it is again. "Thin" packs. I’m thinking to myself, "What |
| 958 | is a <em>thin</em> pack?" So I ask:</p></div> |
| 959 | <div class="literalblock"> |
| 960 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 961 | <pre><code><jdl> What is a "thin" pack?</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 962 | </div></div> |
| 963 | <div class="literalblock"> |
| 964 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 965 | <pre><code><gitster> Use of --objects-edge to rev-list as the upstream of |
| 966 | pack-objects. The pack transfer protocol negotiates that.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 967 | </div></div> |
| 968 | <div class="paragraph"><p>Woo hoo! Cleared that <em>right</em> up!</p></div> |
| 969 | <div class="literalblock"> |
| 970 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 971 | <pre><code><gitster> There are two directions - push and fetch.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 972 | </div></div> |
| 973 | <div class="paragraph"><p>There! Did you see it? It is not <em>"push" and "pull"</em>! How often the |
| 974 | confusion has started here. So casually mentioned, too!</p></div> |
| 975 | <div class="literalblock"> |
| 976 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 977 | <pre><code><gitster> For push, git-send-pack invokes git-receive-pack on the |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 978 | other end. The receive-pack says "I have up to these commits". |
| 979 | send-pack looks at them, and computes what are missing from |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 980 | the other end. So "thin" could be the default there.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 981 | </div></div> |
| 982 | <div class="literalblock"> |
| 983 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 984 | <pre><code>In the other direction, fetch, git-fetch-pack and |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 985 | git-clone-pack invokes git-upload-pack on the other end |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 986 | (via ssh or by talking to the daemon).</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 987 | </div></div> |
| 988 | <div class="literalblock"> |
| 989 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 990 | <pre><code>There are two cases: fetch-pack with -k and clone-pack is one, |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 991 | fetch-pack without -k is the other. clone-pack and fetch-pack |
| 992 | with -k will keep the downloaded packfile without expanded, so |
| 993 | we do not use thin pack transfer. Otherwise, the generated |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 994 | pack will have delta without base object in the same pack.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 995 | </div></div> |
| 996 | <div class="literalblock"> |
| 997 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 998 | <pre><code>But fetch-pack without -k will explode the received pack into |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 999 | individual objects, so we automatically ask upload-pack to |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1000 | give us a thin pack if upload-pack supports it.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1001 | </div></div> |
| 1002 | <div class="paragraph"><p>OK then.</p></div> |
| 1003 | <div class="paragraph"><p>Uh.</p></div> |
| 1004 | <div class="paragraph"><p>Let’s return to the previous conversation still in progress.</p></div> |
| 1005 | <div class="literalblock"> |
| 1006 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1007 | <pre><code><njs`> and "basename" means something like "the tail of end of |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1008 | path of file objects and dir objects, as per basename(3), and |
| 1009 | we just declare all commit and tag objects to have the same |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1010 | basename" or something?</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1011 | </div></div> |
| 1012 | <div class="paragraph"><p>Luckily, that too is a point that gitster clarified for us!</p></div> |
| 1013 | <div class="paragraph"><p>If I might add, the trick is to make files that <em>might</em> be similar be |
| 1014 | located close to each other in the hash buckets based on their file |
| 1015 | names. It used to be that "foo/Makefile", "bar/baz/quux/Makefile" and |
| 1016 | "Makefile" all landed in the same bucket due to their common basename, |
| 1017 | "Makefile". However, now they land in "close" buckets.</p></div> |
| 1018 | <div class="paragraph"><p>The algorithm allows not just for the <em>same</em> bucket, but for <em>close</em> |
| 1019 | buckets to be considered delta candidates. The rationale is |
| 1020 | essentially that files, like Makefiles, often have very similar |
| 1021 | content no matter what directory they live in.</p></div> |
| 1022 | <div class="literalblock"> |
| 1023 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1024 | <pre><code><linus> I played around with different delta algorithms, and with |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1025 | making the "delta window" bigger, but having too big of a |
| 1026 | sliding window makes it very expensive to generate the pack: |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1027 | you need to compare every object with a _ton_ of other objects.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1028 | </div></div> |
| 1029 | <div class="literalblock"> |
| 1030 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1031 | <pre><code>There are a number of other trivial heuristics too, which |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1032 | basically boil down to "don't bother even trying to delta this |
| 1033 | pair" if we can tell before-hand that the delta isn't worth it |
| 1034 | (due to size differences, where we can take a previous delta |
| 1035 | result into account to decide that "ok, no point in trying |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1036 | that one, it will be worse").</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1037 | </div></div> |
| 1038 | <div class="literalblock"> |
| 1039 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1040 | <pre><code>End result: packing is actually very size efficient. It's |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1041 | somewhat CPU-wasteful, but on the other hand, since you're |
| 1042 | really only supposed to do it maybe once a month (and you can |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1043 | do it during the night), nobody really seems to care.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1044 | </div></div> |
| 1045 | <div class="paragraph"><p>Nice Engineering Touch, there. Find when it doesn’t matter, and |
| 1046 | proclaim it a non-issue. Good style too!</p></div> |
| 1047 | <div class="literalblock"> |
| 1048 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1049 | <pre><code><njs`> So, just to repeat to see if I'm following, we start by |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1050 | getting a list of the objects we want to pack, we sort it by |
| 1051 | this heuristic (basically lexicographically on the tuple |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1052 | (type, basename, size)).</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1053 | </div></div> |
| 1054 | <div class="literalblock"> |
| 1055 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1056 | <pre><code>Then we walk through this list, and calculate a delta of |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1057 | each object against the last n (tunable parameter) objects, |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1058 | and pick the smallest of these deltas.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1059 | </div></div> |
| 1060 | <div class="paragraph"><p>Vastly simplified, but the essence is there!</p></div> |
| 1061 | <div class="literalblock"> |
| 1062 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1063 | <pre><code><linus> Correct.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1064 | </div></div> |
| 1065 | <div class="literalblock"> |
| 1066 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1067 | <pre><code><njs`> And then once we have picked a delta or fulltext to |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1068 | represent each object, we re-sort by recency, and write them |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1069 | out in that order.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1070 | </div></div> |
| 1071 | <div class="literalblock"> |
| 1072 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1073 | <pre><code><linus> Yup. Some other small details:</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1074 | </div></div> |
| 1075 | <div class="paragraph"><p>And of course there is the "Other Shoe" Factor too.</p></div> |
| 1076 | <div class="literalblock"> |
| 1077 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1078 | <pre><code><linus> - We limit the delta depth to another magic value (right |
| 1079 | now both the window and delta depth magic values are just "10")</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1080 | </div></div> |
| 1081 | <div class="literalblock"> |
| 1082 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1083 | <pre><code><njs`> Hrm, my intuition is that you'd end up with really _bad_ IO |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1084 | patterns, because the things you want are near by, but to |
| 1085 | actually reconstruct them you may have to jump all over in |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1086 | random ways.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1087 | </div></div> |
| 1088 | <div class="literalblock"> |
| 1089 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1090 | <pre><code><linus> - When we write out a delta, and we haven't yet written |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1091 | out the object it is a delta against, we write out the base |
| 1092 | object first. And no, when we reconstruct them, we actually |
| 1093 | get nice IO patterns, because: |
| 1094 | - larger objects tend to be "more recent" (Linus' law: files grow) |
| 1095 | - we actively try to generate deltas from a larger object to a |
| 1096 | smaller one |
| 1097 | - this means that the top-of-tree very seldom has deltas |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1098 | (i.e. deltas in _practice_ are "backwards deltas")</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1099 | </div></div> |
| 1100 | <div class="paragraph"><p>Again, we should reread that whole paragraph. Not just because |
| 1101 | Linus has slipped Linus’s Law in there on us, but because it is |
| 1102 | important. Let’s make sure we clarify some of the points here:</p></div> |
| 1103 | <div class="literalblock"> |
| 1104 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1105 | <pre><code><njs`> So the point is just that in practice, delta order and |
| 1106 | recency order match each other quite well.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1107 | </div></div> |
| 1108 | <div class="literalblock"> |
| 1109 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1110 | <pre><code><linus> Yes. There's another nice side to this (and yes, it was |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1111 | designed that way ;): |
| 1112 | - the reason we generate deltas against the larger object is |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1113 | actually a big space saver too!</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1114 | </div></div> |
| 1115 | <div class="literalblock"> |
| 1116 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1117 | <pre><code><njs`> Hmm, but your last comment (if "we haven't yet written out |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1118 | the object it is a delta against, we write out the base object |
| 1119 | first"), seems like it would make these facts mostly |
| 1120 | irrelevant because even if in practice you would not have to |
| 1121 | wander around much, in fact you just brute-force say that in |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1122 | the cases where you might have to wander, don't do that :-)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1123 | </div></div> |
| 1124 | <div class="literalblock"> |
| 1125 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1126 | <pre><code><linus> Yes and no. Notice the rule: we only write out the base |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1127 | object first if the delta against it was more recent. That |
| 1128 | means that you can actually have deltas that refer to a base |
| 1129 | object that is _not_ close to the delta object, but that only |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1130 | happens when the delta is needed to generate an _old_ object.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1131 | </div></div> |
| 1132 | <div class="literalblock"> |
| 1133 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1134 | <pre><code><linus> See?</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1135 | </div></div> |
| 1136 | <div class="paragraph"><p>Yeah, no. I missed that on the first two or three readings myself.</p></div> |
| 1137 | <div class="literalblock"> |
| 1138 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1139 | <pre><code><linus> This keeps the front of the pack dense. The front of the |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1140 | pack never contains data that isn't relevant to a "recent" |
| 1141 | object. The size optimization comes from our use of xdelta |
| 1142 | (but is true for many other delta algorithms): removing data |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1143 | is cheaper (in size) than adding data.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1144 | </div></div> |
| 1145 | <div class="literalblock"> |
| 1146 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1147 | <pre><code>When you remove data, you only need to say "copy bytes n--m". |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1148 | In contrast, in a delta that _adds_ data, you have to say "add |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1149 | these bytes: 'actual data goes here'"</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1150 | </div></div> |
| 1151 | <div class="ulist"><ul> |
| 1152 | <li> |
| 1153 | <p> |
| 1154 | njs` has quit: Read error: 104 (Connection reset by peer) |
| 1155 | </p> |
| 1156 | <div class="literalblock"> |
| 1157 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1158 | <pre><code><linus> Uhhuh. I hope I didn't blow njs` mind.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1159 | </div></div> |
| 1160 | </li> |
| 1161 | <li> |
| 1162 | <p> |
| 1163 | njs` has joined channel #git |
| 1164 | </p> |
| 1165 | <div class="literalblock"> |
| 1166 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1167 | <pre><code><pasky> :)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1168 | </div></div> |
| 1169 | </li> |
| 1170 | </ul></div> |
| 1171 | <div class="paragraph"><p>The silent observers are amused. Of course.</p></div> |
| 1172 | <div class="paragraph"><p>And as if njs` was expected to be omniscient:</p></div> |
| 1173 | <div class="literalblock"> |
| 1174 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1175 | <pre><code><linus> njs - did you miss anything?</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1176 | </div></div> |
| 1177 | <div class="paragraph"><p>OK, I’ll spell it out. That’s Geek Humor. If njs` was not actually |
| 1178 | connected for a little bit there, how would he know if missed anything |
| 1179 | while he was disconnected? He’s a benevolent dictator with a sense of |
| 1180 | humor! Well noted!</p></div> |
| 1181 | <div class="literalblock"> |
| 1182 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1183 | <pre><code><njs`> Stupid router. Or gremlins, or whatever.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1184 | </div></div> |
| 1185 | <div class="paragraph"><p>It’s a cheap shot at Cisco. Take 'em when you can.</p></div> |
| 1186 | <div class="literalblock"> |
| 1187 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1188 | <pre><code><njs`> Yes and no. Notice the rule: we only write out the base |
| 1189 | object first if the delta against it was more recent.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1190 | </div></div> |
| 1191 | <div class="literalblock"> |
| 1192 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1193 | <pre><code>I'm getting lost in all these orders, let me re-read :-) |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1194 | So the write-out order is from most recent to least recent? |
| 1195 | (Conceivably it could be the opposite way too, I'm not sure if |
| 1196 | we've said) though my connection back at home is logging, so I |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1197 | can just read what you said there :-)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1198 | </div></div> |
| 1199 | <div class="paragraph"><p>And for those of you paying attention, the Omniscient Trick has just |
| 1200 | been detailed!</p></div> |
| 1201 | <div class="literalblock"> |
| 1202 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1203 | <pre><code><linus> Yes, we always write out most recent first</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1204 | </div></div> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1205 | <div class="literalblock"> |
| 1206 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1207 | <pre><code><njs`> And, yeah, I got the part about deeper-in-history stuff |
| 1208 | having worse IO characteristics, one sort of doesn't care.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1209 | </div></div> |
| 1210 | <div class="literalblock"> |
| 1211 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1212 | <pre><code><linus> With the caveat that if the "most recent" needs an older |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1213 | object to delta against (hey, shrinking sometimes does |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1214 | happen), we write out the old object with the delta.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1215 | </div></div> |
| 1216 | <div class="literalblock"> |
| 1217 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1218 | <pre><code><njs`> (if only it happened more...)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1219 | </div></div> |
| 1220 | <div class="literalblock"> |
| 1221 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1222 | <pre><code><linus> Anyway, the pack-file could easily be denser still, but |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1223 | because it's used both for streaming (the Git protocol) and |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1224 | for on-disk, it has a few pessimizations.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1225 | </div></div> |
| 1226 | <div class="paragraph"><p>Actually, it is a made-up word. But it is a made-up word being |
| 1227 | used as setup for a later optimization, which is a real word:</p></div> |
| 1228 | <div class="literalblock"> |
| 1229 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1230 | <pre><code><linus> In particular, while the pack-file is then compressed, |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1231 | it's compressed just one object at a time, so the actual |
| 1232 | compression factor is less than it could be in theory. But it |
| 1233 | means that it's all nice random-access with a simple index to |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1234 | do "object name->location in packfile" translation.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1235 | </div></div> |
| 1236 | <div class="literalblock"> |
| 1237 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1238 | <pre><code><njs`> I'm assuming the real win for delta-ing large->small is |
| 1239 | more homogeneous statistics for gzip to run over?</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1240 | </div></div> |
| 1241 | <div class="literalblock"> |
| 1242 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1243 | <pre><code>(You have to put the bytes in one place or another, but |
| 1244 | putting them in a larger blob wins on compression)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1245 | </div></div> |
| 1246 | <div class="literalblock"> |
| 1247 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1248 | <pre><code>Actually, what is the compression strategy -- each delta |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1249 | individually gzipped, the whole file gzipped, somewhere in |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1250 | between, no compression at all, ....?</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1251 | </div></div> |
| 1252 | <div class="literalblock"> |
| 1253 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1254 | <pre><code>Right.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1255 | </div></div> |
| 1256 | <div class="paragraph"><p>Reality IRC sets in. For example:</p></div> |
| 1257 | <div class="literalblock"> |
| 1258 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1259 | <pre><code><pasky> I'll read the rest in the morning, I really have to go |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1260 | sleep or there's no hope whatsoever for me at the today's |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1261 | exam... g'nite all.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1262 | </div></div> |
| 1263 | <div class="paragraph"><p>Heh.</p></div> |
| 1264 | <div class="literalblock"> |
| 1265 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1266 | <pre><code><linus> pasky: g'nite</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1267 | </div></div> |
| 1268 | <div class="literalblock"> |
| 1269 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1270 | <pre><code><njs`> pasky: 'luck</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1271 | </div></div> |
| 1272 | <div class="literalblock"> |
| 1273 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1274 | <pre><code><linus> Right: large->small matters exactly because of compression |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1275 | behaviour. If it was non-compressed, it probably wouldn't make |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1276 | any difference.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1277 | </div></div> |
| 1278 | <div class="literalblock"> |
| 1279 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1280 | <pre><code><njs`> yeah</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1281 | </div></div> |
| 1282 | <div class="literalblock"> |
| 1283 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1284 | <pre><code><linus> Anyway: I'm not even trying to claim that the pack-files |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1285 | are perfect, but they do tend to have a nice balance of |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1286 | density vs ease-of use.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1287 | </div></div> |
| 1288 | <div class="paragraph"><p>Gasp! OK, saved. That’s a fair Engineering trade off. Close call! |
| 1289 | In fact, Linus reflects on some Basic Engineering Fundamentals, |
| 1290 | design options, etc.</p></div> |
| 1291 | <div class="literalblock"> |
| 1292 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1293 | <pre><code><linus> More importantly, they allow Git to still _conceptually_ |
| 1294 | never deal with deltas at all, and be a "whole object" store.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1295 | </div></div> |
| 1296 | <div class="literalblock"> |
| 1297 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1298 | <pre><code>Which has some problems (we discussed bad huge-file |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1299 | behaviour on the Git lists the other day), but it does mean |
| 1300 | that the basic Git concepts are really really simple and |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1301 | straightforward.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1302 | </div></div> |
| 1303 | <div class="literalblock"> |
| 1304 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1305 | <pre><code>It's all been quite stable.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1306 | </div></div> |
| 1307 | <div class="literalblock"> |
| 1308 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1309 | <pre><code>Which I think is very much a result of having very simple |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1310 | basic ideas, so that there's never any confusion about what's |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1311 | going on.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1312 | </div></div> |
| 1313 | <div class="literalblock"> |
| 1314 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1315 | <pre><code>Bugs happen, but they are "simple" bugs. And bugs that |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1316 | actually get some object store detail wrong are almost always |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1317 | so obvious that they never go anywhere.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1318 | </div></div> |
| 1319 | <div class="literalblock"> |
| 1320 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1321 | <pre><code><njs`> Yeah.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1322 | </div></div> |
| 1323 | <div class="paragraph"><p>Nuff said.</p></div> |
| 1324 | <div class="literalblock"> |
| 1325 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1326 | <pre><code><linus> Anyway. I'm off for bed. It's not 6AM here, but I've got |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1327 | three kids, and have to get up early in the morning to send |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1328 | them off. I need my beauty sleep.</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1329 | </div></div> |
| 1330 | <div class="literalblock"> |
| 1331 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1332 | <pre><code><njs`> :-)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1333 | </div></div> |
| 1334 | <div class="literalblock"> |
| 1335 | <div class="content"> |
Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1336 | <pre><code><njs`> appreciate the infodump, I really was failing to find the |
| 1337 | details on Git packs :-)</code></pre> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1338 | </div></div> |
| 1339 | <div class="paragraph"><p>And now you know the rest of the story.</p></div> |
| 1340 | </div> |
Junio C Hamano | bc8d478 | 2014-01-13 23:35:50 | [diff] [blame] | 1341 | </div> |
| 1342 | </div> |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1343 | <div id="footnotes"><hr /></div> |
| 1344 | <div id="footer"> |
| 1345 | <div id="footer-text"> |
Junio C Hamano | 2ef0ba3 | 2018-01-26 23:13:53 | [diff] [blame] | 1346 | Last updated |
Junio C Hamano | 918a697 | 2023-10-29 23:44:11 | [diff] [blame] | 1347 | 2020-03-11 07:02:33 JST |
Junio C Hamano | f2b7494 | 2012-11-20 21:06:26 | [diff] [blame] | 1348 | </div> |
| 1349 | </div> |
| 1350 | </body> |
| 1351 | </html> |