git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 01/23] midx: add design document

From
Stefan Beller <sbeller@google.com>
Date
Jun 11, 2018, 19:04 UTC
Message-ID
<CAGZ79ka4RD_E5NpEf8-7BUCcoqEc+hDrHNR+YAqT=6m5TYg7mg@mail.gmail.com>
In-Reply-To
<20180607140338.32440-2-dstolee@microsoft.com>
On Thu, Jun 7, 2018 at 7:03 AM Derrick Stolee <stolee@gmail.com> wrote:
Show 28 quoted lines
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
> ---
>  Documentation/technical/midx.txt | 109 +++++++++++++++++++++++++++++++
>  1 file changed, 109 insertions(+)
>  create mode 100644 Documentation/technical/midx.txt
>
> diff --git a/Documentation/technical/midx.txt b/Documentation/technical/midx.txt
> new file mode 100644
> index 0000000000..789f410d71
> --- /dev/null
> +++ b/Documentation/technical/midx.txt
> @@ -0,0 +1,109 @@
> +Multi-Pack-Index (MIDX) Design Notes
> +====================================
> +
> +The Git object directory contains a 'pack' directory containing
> +packfiles (with suffix ".pack") and pack-indexes (with suffix
> +".idx"). The pack-indexes provide a way to lookup objects and
> +navigate to their offset within the pack, but these must come
> +in pairs with the packfiles. This pairing depends on the file
> +names, as the pack-index differs only in suffix with its pack-
> +file. While the pack-indexes provide fast lookup per packfile,
> +this performance degrades as the number of packfiles increases,
> +because abbreviations need to inspect every packfile and we are
> +more likely to have a miss on our most-recently-used packfile.
> +For some large repositories, repacking into a single packfile
> +is not feasible due to storage space or excessive repack times.

This leads to the question how MIDX will cope with large repos or a large number of packs. As it is just an index and not a pack itself, I guess it is smaller by some orders of magnitude, such that it is ok for now.

Show 13 quoted lines
> +The multi-pack-index (MIDX for short) stores a list of objects
> +and their offsets into multiple packfiles. It contains:
> +
> +- A list of packfile names.
> +- A sorted list of object IDs.
> +- A list of metadata for the ith object ID including:
> +  - A value j referring to the jth packfile.
> +  - An offset within the jth packfile for the object.
> +- If large offsets are required, we use another list of large
> +  offsets similar to version 2 pack-indexes.
> +
> +Thus, we can provide O(log N) lookup time for any number
> +of packfiles.

This sounds great for the lookup case! Though that is for the repo-read case. Let's read on how the dynamics of a repository are dealt with, e.g. integrating new packs into the MIDX, or how we deal with objects in multiple packs.

Show 8 quoted lines
> +
> +Design Details
> +--------------
> +
> +- The MIDX is stored in a file named 'multi-pack-index' in the
> +  .git/objects/pack directory. This could be stored in the pack
> +  directory of an alternate. It refers only to packfiles in that
> +  same directory.

So there is one and only one multi pack index? That makes the case of preparing the next MIDX that contains more pack references more interesting, as then we have to atomically update that file.

> +- The core.midx config setting must be on to consume MIDX files.

Looking through current config options, I would rename this to a more suggestive name. I searched for the core.idx counterpart that enables idx files -- it turns out that is named pack.indexVersion.

So maybe pack.MultiIndex ? That could start out as a boolean as in this series and then evolve into a version number or such later.

Show 7 quoted lines
> +- The file format includes parameters for the object ID hash
> +  function, so a future change of hash algorithm does not require
> +  a change in format.
> +
> +- The MIDX keeps only one record per object ID. If an object appears
> +  in multiple packfiles, then the MIDX selects the copy in the most-
> +  recently modified packfile.

Okay. That answers the question from above. Though this is just the tie breaking decision and not a hard limitation? (i.e. we could change this this later to that pack that has e.g. shortest delta chain for that object or such)

> +- If there exist packfiles in the pack directory not registered in
> +  the MIDX, then those packfiles are loaded into the `packed_git`
> +  list and `packed_git_mru` cache.

Not sure I understand the implications of this? Does that mean we first look at the multi index and if an object is not found, we'll search linearly through all packs that are not part of the MIDX? That would require the MIDX to be kepot up to date reasonably to be useful.

> +- The pack-indexes (.idx files) remain in the pack directory so we
> +  can delete the MIDX file, set core.midx to false, or downgrade
> +  without any loss of information.

In the future will it be possible to have no .idx files and just have the .midx? (I guess that depends on the strategy of how to integrate new packs into the MIDX?)

> +- The MIDX file format uses a chunk-based approach (similar to the
> +  commit-graph file) that allows optional data to be added.

... or the index files v2 (or reftable files)? Sure, you are most familiar with commit-graph files, but others may find it easier to have some older file formats to relate to.

Show 11 quoted lines
> +Future Work
> +-----------
> +
> +- Add a 'verify' subcommand to the 'git midx' builtin to verify the
> +  contents of the multi-pack-index file match the offsets listed in
> +  the corresponding pack-indexes.
> +
> +- The multi-pack-index allows many packfiles, especially in a context
> +  where repacking is expensive (such as a very large repo), or
> +  unexpected maintenance time is unacceptable (such as a high-demand
> +  build machine).

Supposedly maintenance (git gc) can be run in the background without interfering with day-to-day life, how is the regeneration of commit graph or MIDX files impacting the work here?

Show 6 quoted lines
>     However, the multi-pack-index needs to be rewritten
> +  in full every time. We can extend the format to be incremental, so
> +  writes are fast. By storing a small "tip" multi-pack-index that
> +  points to large "base" MIDX files, we can keep writes fast while
> +  still reducing the number of binary searches required for object
> +  lookups.

So we can have multiple MIDX files? How would that work? Would there be a chunk that refers to other MIDX files?

Show 6 quoted lines
> +- The reachability bitmap is currently paired directly with a single
> +  packfile, using the pack-order as the object order to hopefully
> +  compress the bitmaps well using run-length encoding. This could be
> +  extended to pair a reachability bitmap with a multi-pack-index. If
> +  the multi-pack-index is extended to store a "stable object order"
> +  (a function Order(hash) = integer that is constant for a given hash,
This stable object order doesn't fly well with integrating new packs?
Show 16 quoted lines
> +  even as the multi-pack-index is updated) then a reachability bitmap
> +  could point to a multi-pack-index and be updated independently.
> +
> +- Packfiles can be marked as "special" using empty files that share
> +  the initial name but replace ".pack" with ".keep" or ".promisor".
> +  We can add an optional chunk of data to the multi-pack-index that
> +  records flags of information about the packfiles. This allows new
> +  states, such as 'repacked' or 'redeltified', that can help with
> +  pack maintenance in a multi-pack environment. It may also be
> +  helpful to organize packfiles by object type (commit, tree, blob,
> +  etc.) and use this metadata to help that maintenance.
> +
> +- The partial clone feature records special "promisor" packs that
> +  may point to objects that are not stored locally, but available
> +  on request to a server. The multi-pack-index does not currently
> +  track these promisor packs.
Previous: Derrick StoleeNext: Derrick Stolee
Message 3 of 192 in “Multi-pack-index (MIDX)”
  1. 00/23 Multi-pack-index (MIDX)Derrick Stolee, Jun 7, 2018
  2. 01/23 midx: add design documentDerrick Stolee, Jun 7, 2018
  3. Stefan BellerJun 11, 2018
  4. Derrick StoleeJun 18, 2018
  5. 03/23 midx: add midx builtinDerrick Stolee, Jun 7, 2018
  6. Duy NguyenJun 7, 2018
  7. Derrick StoleeJun 18, 2018
  8. Stefan BellerJun 11, 2018
  9. Derrick StoleeJun 18, 2018
  10. Stefan BellerJun 18, 2018
  11. Derrick StoleeJun 18, 2018
  12. 04/23 midx: add 'write' subcommand and basic wiringDerrick Stolee, Jun 7, 2018
  13. Duy NguyenJun 7, 2018
  14. 09/23 midx: write pack names in chunkDerrick Stolee, Jun 7, 2018
  15. Duy NguyenJun 7, 2018
  16. Derrick StoleeJun 21, 2018
  17. Junio C HamanoJun 21, 2018
  18. Derrick StoleeJun 22, 2018
  19. Junio C HamanoJun 22, 2018
  20. Derrick StoleeJun 22, 2018
  21. 12/23 midx: write object ids in a chunkDerrick Stolee, Jun 7, 2018
  22. Duy NguyenJun 9, 2018
  23. 10/23 midx: write a lookup into the pack names chunkDerrick Stolee, Jun 7, 2018
  24. Duy NguyenJun 9, 2018
  25. Derrick StoleeJun 21, 2018
  26. 16/23 midx: prepare midxed_git structDerrick Stolee, Jun 7, 2018
  27. Duy NguyenJun 9, 2018
  28. 11/23 midx: sort and deduplicate objects from packfilesDerrick Stolee, Jun 7, 2018
  29. Duy NguyenJun 9, 2018
  30. Derrick StoleeJun 21, 2018
  31. 21/23 midx: prevent duplicate packfile loadsDerrick Stolee, Jun 7, 2018
  32. Duy NguyenJun 9, 2018
  33. 23/23 midx: clear midx on repackDerrick Stolee, Jun 7, 2018
  34. Duy NguyenJun 9, 2018
  35. Derrick StoleeJun 22, 2018
  36. 22/23 midx: use midx to find ref-deltasDerrick Stolee, Jun 7, 2018
  37. 13/23 midx: write object id fanout chunkDerrick Stolee, Jun 7, 2018
  38. Duy NguyenJun 9, 2018
  39. Derrick StoleeJun 21, 2018
  40. 14/23 midx: write object offsetsDerrick Stolee, Jun 7, 2018
  41. Duy NguyenJun 9, 2018
  42. 20/23 midx: use midx in approximate_object_countDerrick Stolee, Jun 7, 2018
  43. Duy NguyenJun 9, 2018
  44. Derrick StoleeJun 22, 2018
  45. 19/23 midx: use existing midx when writing new oneDerrick Stolee, Jun 7, 2018
  46. 15/23 midx: create core.midx config settingDerrick Stolee, Jun 7, 2018
  47. 18/23 midx: use midx in abbreviation calculationsDerrick Stolee, Jun 7, 2018
  48. Duy NguyenJun 9, 2018
  49. Derrick StoleeJun 22, 2018
  50. 17/23 midx: read objects from multi-pack-indexDerrick Stolee, Jun 7, 2018
  51. Duy NguyenJun 9, 2018
  52. Derrick StoleeJun 21, 2018
  53. 05/23 midx: write header information to lockfileDerrick Stolee, Jun 7, 2018
  54. Duy NguyenJun 7, 2018
  55. Duy NguyenJun 12, 2018
  56. Derrick StoleeJun 19, 2018
  57. Duy NguyenJun 19, 2018
  58. Derrick StoleeJun 19, 2018
  59. 08/23 midx: read packfiles from pack directoryDerrick Stolee, Jun 7, 2018
  60. Duy NguyenJun 7, 2018
  61. packfile: generalize pack directory listDerrick Stolee, Jun 20, 2018
  62. 07/23 midx: expand test dataDerrick Stolee, Jun 7, 2018
  63. 06/23 midx: struct midxed_git and 'read' subcommandDerrick Stolee, Jun 7, 2018
  64. Duy NguyenJun 7, 2018
  65. Derrick StoleeJun 20, 2018
  66. Duy NguyenJun 7, 2018
  67. Derrick StoleeJun 20, 2018
  68. Duy NguyenJun 20, 2018
  69. Derrick StoleeJun 20, 2018
  70. 02/23 midx: add midx format details to pack-format.txtDerrick Stolee, Jun 7, 2018
  71. Stefan BellerJun 11, 2018
  72. Derrick StoleeJun 18, 2018
  73. Stefan BellerJun 18, 2018
  74. Derrick StoleeJun 7, 2018
  75. Ævar Arnfjörð BjarmasonJun 7, 2018
  76. Derrick StoleeJun 7, 2018
  77. 00/24 Multi-pack-index (MIDX)Derrick Stolee, Jun 25, 2018
  78. 01/24 multi-pack-index: add design documentDerrick Stolee, Jun 25, 2018
  79. 02/24 multi-pack-index: add format detailsDerrick Stolee, Jun 25, 2018
  80. 04/24 multi-pack-index: add 'write' verbDerrick Stolee, Jun 25, 2018
  81. 03/24 multi-pack-index: add builtinDerrick Stolee, Jun 25, 2018
  82. Junio C HamanoJun 25, 2018
  83. 05/24 midx: write header information to lockfileDerrick Stolee, Jun 25, 2018
  84. Junio C HamanoJun 25, 2018
  85. Derrick StoleeJul 5, 2018
  86. 08/24 packfile: generalize pack directory listDerrick Stolee, Jun 25, 2018
  87. Junio C HamanoJun 25, 2018
  88. 09/24 multi-pack-index: read packfile listDerrick Stolee, Jun 25, 2018
  89. 06/24 multi-pack-index: load into memoryDerrick Stolee, Jun 25, 2018
  90. Junio C HamanoJun 25, 2018
  91. Derrick StoleeJul 5, 2018
  92. Eric SunshineJul 5, 2018
  93. Junio C HamanoJul 6, 2018
  94. 11/24 midx: read pack names into arrayDerrick Stolee, Jun 25, 2018
  95. Eric SunshineJun 25, 2018
  96. 12/24 midx: sort and deduplicate objects from packfilesDerrick Stolee, Jun 25, 2018
  97. 13/24 midx: write object ids in a chunkDerrick Stolee, Jun 25, 2018
  98. 14/24 midx: write object id fanout chunkDerrick Stolee, Jun 25, 2018
  99. 15/24 midx: write object offsetsDerrick Stolee, Jun 25, 2018
  100. 16/24 config: create core.multiPackIndex settingDerrick Stolee, Jun 25, 2018
  101. 18/24 midx: read objects from multi-pack-indexDerrick Stolee, Jun 25, 2018
  102. 10/24 multi-pack-index: write pack names in chunkDerrick Stolee, Jun 25, 2018
  103. 19/24 midx: use midx in abbreviation calculationsDerrick Stolee, Jun 25, 2018
  104. 17/24 midx: prepare midxed_git structDerrick Stolee, Jun 25, 2018
  105. 23/24 packfile: skip loading index if in multi-pack-indexDerrick Stolee, Jun 25, 2018
  106. 24/24 midx: clear midx on repackDerrick Stolee, Jun 25, 2018
  107. 20/24 midx: use existing midx when writing new oneDerrick Stolee, Jun 25, 2018
  108. 22/24 midx: prevent duplicate packfile loadsDerrick Stolee, Jun 25, 2018
  109. 21/24 midx: use midx in approximate_object_countDerrick Stolee, Jun 25, 2018
  110. 07/24 multi-pack-index: expand test dataDerrick Stolee, Jun 25, 2018
  111. Junio C HamanoJun 25, 2018
  112. 00/24 Multi-pack-index (MIDX)Derrick Stolee, Jul 6, 2018
  113. 01/24 multi-pack-index: add design documentDerrick Stolee, Jul 6, 2018
  114. 02/24 multi-pack-index: add format detailsDerrick Stolee, Jul 6, 2018
  115. 04/24 multi-pack-index: add 'write' verbDerrick Stolee, Jul 6, 2018
  116. Eric SunshineJul 6, 2018
  117. 03/24 multi-pack-index: add builtinDerrick Stolee, Jul 6, 2018
  118. Eric SunshineJul 6, 2018
  119. 05/24 midx: write header information to lockfileDerrick Stolee, Jul 6, 2018
  120. 08/24 packfile: generalize pack directory listDerrick Stolee, Jul 6, 2018
  121. 06/24 multi-pack-index: load into memoryDerrick Stolee, Jul 6, 2018
  122. Eric SunshineJul 6, 2018
  123. Eric SunshineJul 6, 2018
  124. Junio C HamanoJul 9, 2018
  125. Derrick StoleeJul 12, 2018
  126. 09/24 multi-pack-index: read packfile listDerrick Stolee, Jul 6, 2018
  127. 10/24 multi-pack-index: write pack names in chunkDerrick Stolee, Jul 6, 2018
  128. 13/24 midx: write object ids in a chunkDerrick Stolee, Jul 6, 2018
  129. Eric SunshineJul 6, 2018
  130. 12/24 midx: sort and deduplicate objects from packfilesDerrick Stolee, Jul 6, 2018
  131. 14/24 midx: write object id fanout chunkDerrick Stolee, Jul 6, 2018
  132. 15/24 midx: write object offsetsDerrick Stolee, Jul 6, 2018
  133. Eric SunshineJul 6, 2018
  134. Derrick StoleeJul 12, 2018
  135. 18/24 midx: read objects from multi-pack-indexDerrick Stolee, Jul 6, 2018
  136. 19/24 midx: use midx in abbreviation calculationsDerrick Stolee, Jul 6, 2018
  137. 20/24 midx: use existing midx when writing new oneDerrick Stolee, Jul 6, 2018
  138. 24/24 midx: clear midx on repackDerrick Stolee, Jul 6, 2018
  139. Eric SunshineJul 6, 2018
  140. 21/24 midx: use midx in approximate_object_countDerrick Stolee, Jul 6, 2018
  141. 22/24 midx: prevent duplicate packfile loadsDerrick Stolee, Jul 6, 2018
  142. 23/24 packfile: skip loading index if in multi-pack-indexDerrick Stolee, Jul 6, 2018
  143. 16/24 config: create core.multiPackIndex settingDerrick Stolee, Jul 6, 2018
  144. Eric SunshineJul 6, 2018
  145. Derrick StoleeJul 12, 2018
  146. Derrick StoleeJul 12, 2018
  147. SZEDER GáborJul 11, 2018
  148. Derrick StoleeJul 12, 2018
  149. SZEDER GáborJul 12, 2018
  150. Derrick StoleeJul 12, 2018
  151. Junio C HamanoJul 12, 2018
  152. 17/24 midx: prepare midxed_git structDerrick Stolee, Jul 6, 2018
  153. Eric SunshineJul 6, 2018
  154. 07/24 multi-pack-index: expand test dataDerrick Stolee, Jul 6, 2018
  155. Eric SunshineJul 6, 2018
  156. Eric SunshineJul 6, 2018
  157. Derrick StoleeJul 12, 2018
  158. Eric SunshineJul 12, 2018
  159. Derrick StoleeJul 12, 2018
  160. 11/24 midx: read pack names into arrayDerrick Stolee, Jul 6, 2018
  161. Eric SunshineJul 6, 2018
  162. 00/23 Multi-pack-index (MIDX)Derrick Stolee, Jul 12, 2018
  163. 02/23 multi-pack-index: add format detailsDerrick Stolee, Jul 12, 2018
  164. 01/23 multi-pack-index: add design documentDerrick Stolee, Jul 12, 2018
  165. 03/23 multi-pack-index: add builtinDerrick Stolee, Jul 12, 2018
  166. Junio C HamanoJul 20, 2018
  167. brian m. carlsonJul 20, 2018
  168. Junio C HamanoJul 20, 2018
  169. 04/23 multi-pack-index: add 'write' verbDerrick Stolee, Jul 12, 2018
  170. Eric SunshineJul 12, 2018
  171. 06/23 multi-pack-index: load into memoryDerrick Stolee, Jul 12, 2018
  172. 05/23 midx: write header information to lockfileDerrick Stolee, Jul 12, 2018
  173. 07/23 t5319: expand test dataDerrick Stolee, Jul 12, 2018
  174. 08/23 packfile: generalize pack directory listDerrick Stolee, Jul 12, 2018
  175. 09/23 multi-pack-index: read packfile listDerrick Stolee, Jul 12, 2018
  176. 11/23 midx: read pack names into arrayDerrick Stolee, Jul 12, 2018
  177. 10/23 multi-pack-index: write pack names in chunkDerrick Stolee, Jul 12, 2018
  178. 12/23 midx: sort and deduplicate objects from packfilesDerrick Stolee, Jul 12, 2018
  179. 13/23 midx: write object ids in a chunkDerrick Stolee, Jul 12, 2018
  180. 14/23 midx: write object id fanout chunkDerrick Stolee, Jul 12, 2018
  181. 15/23 midx: write object offsetsDerrick Stolee, Jul 12, 2018
  182. 16/23 config: create core.multiPackIndex settingDerrick Stolee, Jul 12, 2018
  183. Junio C HamanoJul 12, 2018
  184. Derrick StoleeJul 13, 2018
  185. 17/23 midx: read objects from multi-pack-indexDerrick Stolee, Jul 12, 2018
  186. 18/23 midx: use midx in abbreviation calculationsDerrick Stolee, Jul 12, 2018
  187. 19/23 midx: use existing midx when writing new oneDerrick Stolee, Jul 12, 2018
  188. 20/23 midx: use midx in approximate_object_countDerrick Stolee, Jul 12, 2018
  189. 21/23 midx: prevent duplicate packfile loadsDerrick Stolee, Jul 12, 2018
  190. 23/23 midx: clear midx on repackDerrick Stolee, Jul 12, 2018
  191. 22/23 packfile: skip loading index if in multi-pack-indexDerrick Stolee, Jul 12, 2018
  192. Junio C HamanoJul 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.