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

Re: [PATCH v5 02/17] pack-mtimes: support reading .mtimes files

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 25, 2022, 07:48 UTC
Message-ID
<Yo3fZkpkCLPbAC8B@google.com>
In-Reply-To
<Yo1aaLDmPKJ5/rh5@nand.local>
Hi,
Taylor Blau wrote:
> On Tue, May 24, 2022 at 12:32:01PM -0700, Jonathan Nieder wrote:
>> Makes sense.  Does this intend to produce any functional change?  I'm
>> guessing not (and the lack of tests agrees), but the commit message
>> doesn't say so.
[...]
> This does not produce a functional change, no. This commit in isolation
> adds a bunch of dead code that will be used (and tested) in the
> following patches.
[...]
>> What does mtimes_map contain?  A comment would help.
>
> It contains a pointer at the beginning of the mmapped region of the
> .mtimes file, similar to revindex_map above it.

To be clear, in cases like this by "comment" I mean "in-code comment". I.e., my interest is not that _I_ find out the answer but that the code becomes more maintainable via the answer becoming easier to find.

[...]
Show 7 quoted lines
>> This seems simple enough that it's not obvious we need more code
>> sharing.  Do you agree?  If so, I'd suggest just removing the
>> NEEDSWORK comment.
>
> Yeah, it is conceptually simple, though it feels like the sort of thing
> that could benefit from not having to be written once for each
> extension (hence the comment).

The reason I asked is that the NEEDSWORK here actually got in the way of comprehension for me --- it made me wonder "is there some complexity here I'm missing?"

That's why I'd suggest one of
- removing the NEEDSWORK comment
- going ahead and implementing the code sharing you mean, or
- fleshing out the NEEDSWORK comment so the reader can wonder less
Show 13 quoted lines
>>> +
>>> +#define MTIMES_HEADER_SIZE (12)
>>> +#define MTIMES_MIN_SIZE (MTIMES_HEADER_SIZE + (2 * the_hash_algo->rawsz))
>>
>> Hm, the all-caps name makes this feel like a compile-time constant but
>> it contains a reference to the_hash_algo.  Could it be an inline
>> function instead?
>
> Yes, it could be an inline function, but I don't think there is
> necessarily anything wrong with it being a #define'd macro. There are
> some other examples, e.g., RIDX_MIN_SIZE, MIDX_MIN_SIZE,
> GRAPH_DATA_WIDTH, and PACK_SIZE_THRESHOLD (to name a few) which also use
> the_hash_algo on the right-hand side of a `#define`.

Those are due to an incomplete migration from use of the true constant GIT_SHA1_RAWSZ to use of the dynamic value the_hash_algo->rawsz, no? In other words, "other examples do it wrong" doesn't feel like a great justification for making it worse in new code.

[...]
Show 10 quoted lines
>>> +static int load_pack_mtimes_file(char *mtimes_file,
>>> +				 uint32_t num_objects,
>>> +				 const uint32_t **data_p, size_t *len_p)
>>
>> What does this function do?  A comment would help.
>
> I know that I'm biased as the author of this code, but I think the
> signature is clear here. At least, I'm not sure what information a
> comment would add that the function name and its arguments don't already
> convey.
Ah, thanks for this point of clarification.  What isn't clear from the
signature is
- when should I call this function?
- what does its return value represent?
- how does it handle errors?
I agree that the parameters are self-explanatory.
Show 22 quoted lines
>>> +cleanup:
>>> +	if (ret) {
>>> +		if (data)
>>> +			munmap(data, mtimes_size);
>>> +	} else {
>>> +		*len_p = mtimes_size;
>>> +		*data_p = (const uint32_t *)data;
>>
>> Do we know that 'data' is uint32_t aligned?  Casting earlier in the
>> function could make that more obvious.
>
> `data` is definitely uint32_t aligned, but this is a tradeoff, since if
> we wrote:
>
>     uint32_t *data = xmmap(...);
>
> then I think we would have to change the case where ret is non-zero to be:
>
>     if (data)
>         munmap((void*)data, ...);
>
> and likewise, data_p is const.

Doing it that way sounds great to me. That way, the type contains the information we need up-front and the safety of the cast is obvious in the place where the cast is needed.

(Although my understanding is also that in C it's fine to pass a uint32_t* to a function expecting a void*, so the second cast would also not be needed.)

[...]
Show 14 quoted lines
>>> +int load_pack_mtimes(struct packed_git *p)
>>
>> This could use a doc comment in the header file.  For example, what
>> requirements do we have on what the caller passes as 'p'?
>>
>> [...]
>>> +uint32_t nth_packed_mtime(struct packed_git *p, uint32_t pos)
>>
>> Likewise.
>
> Sure. I wonder when we should do that, though. I'm not trying to be
> impatient to get this merged, but iterating on the documentation feels
> like it could be done on top without having to re-send the substantive
> parts of this series over and over.

In terms of re-sending patches, sending a "fixup!" patch with the minor changes you want to make doesn't seem too problematic to me. In general a major benefit of code review is getting others' eyes on new code from the standpoint of readability and maintainability; including comments like this up front doesn't seem like a huge amount to ask (versus getting those comments to be perfect, which would be unreasonable to expect since it's not hard to update them over time).

> Thanks,
> Taylor
Thanks for looking it through.

Sincerely, Jonathan

Previous: Taylor BlauNext: Taylor Blau
Message 174 of 201 in “cruft packs”
  1. 00/17 cruft packsTaylor Blau, Nov 29, 2021
  2. 01/17 Documentation/technical: add cruft-packs.txtTaylor Blau, Nov 29, 2021
  3. Derrick StoleeDec 2, 2021
  4. Taylor BlauDec 3, 2021
  5. Elijah NewrenDec 4, 2021
  6. Taylor BlauDec 4, 2021
  7. 02/17 pack-mtimes: support reading .mtimes filesTaylor Blau, Nov 29, 2021
  8. Derrick StoleeDec 2, 2021
  9. brian m. carlsonDec 2, 2021
  10. Taylor BlauDec 3, 2021
  11. Taylor BlauJan 7, 2022
  12. 04/17 chunk-format.h: extract oid_version()Taylor Blau, Nov 29, 2021
  13. Derrick StoleeDec 2, 2021
  14. Taylor BlauDec 3, 2021
  15. Derrick StoleeDec 6, 2021
  16. 03/17 pack-write: pass 'struct packing_data' to 'stage_tmp_packfiles'Taylor Blau, Nov 29, 2021
  17. 05/17 pack-mtimes: support writing pack .mtimes filesTaylor Blau, Nov 29, 2021
  18. Derrick StoleeDec 2, 2021
  19. Taylor BlauDec 3, 2021
  20. 09/17 reachable: add options to add_unseen_recent_objects_to_traversalTaylor Blau, Nov 29, 2021
  21. 13/17 builtin/repack.c: allow configuring cruft pack generationTaylor Blau, Nov 29, 2021
  22. 06/17 t/helper: add 'pack-mtimes' test-toolTaylor Blau, Nov 29, 2021
  23. Derrick StoleeDec 6, 2021
  24. Taylor BlauFeb 23, 2022
  25. 11/17 builtin/pack-objects.c: --cruft with expirationTaylor Blau, Nov 29, 2021
  26. Derrick StoleeDec 7, 2021
  27. Taylor BlauFeb 23, 2022
  28. 10/17 reachable: report precise timestamps from objects in cruft packsTaylor Blau, Nov 29, 2021
  29. 07/17 builtin/pack-objects.c: return from create_object_entry()Taylor Blau, Nov 29, 2021
  30. 08/17 builtin/pack-objects.c: --cruft without expirationTaylor Blau, Nov 29, 2021
  31. Derrick StoleeDec 6, 2021
  32. Taylor BlauMar 1, 2022
  33. Derrick StoleeDec 7, 2021
  34. Taylor BlauFeb 23, 2022
  35. 12/17 builtin/repack.c: support generating a cruft packTaylor Blau, Nov 29, 2021
  36. Junio C HamanoDec 5, 2021
  37. Taylor BlauMar 1, 2022
  38. Derrick StoleeDec 7, 2021
  39. Taylor BlauFeb 23, 2022
  40. 15/17 builtin/repack.c: add cruft packs to MIDX during geometric repackTaylor Blau, Nov 29, 2021
  41. 16/17 builtin/gc.c: conditionally avoid pruning objects via looseTaylor Blau, Nov 29, 2021
  42. 17/17 sha1-file.c: don't freshen cruft packsTaylor Blau, Nov 29, 2021
  43. 14/17 builtin/repack.c: use named flags for existing_packsTaylor Blau, Nov 29, 2021
  44. Junio C HamanoDec 3, 2021
  45. Taylor BlauDec 3, 2021
  46. Taylor BlauDec 3, 2021
  47. 00/17 cruft packsTaylor Blau, Mar 2, 2022
  48. 01/17 Documentation/technical: add cruft-packs.txtTaylor Blau, Mar 2, 2022
  49. 03/17 pack-write: pass 'struct packing_data' to 'stage_tmp_packfiles'Taylor Blau, Mar 2, 2022
  50. 02/17 pack-mtimes: support reading .mtimes filesTaylor Blau, Mar 2, 2022
  51. Derrick StoleeMar 2, 2022
  52. Taylor BlauMar 2, 2022
  53. 04/17 chunk-format.h: extract oid_version()Taylor Blau, Mar 2, 2022
  54. 06/17 t/helper: add 'pack-mtimes' test-toolTaylor Blau, Mar 2, 2022
  55. 05/17 pack-mtimes: support writing pack .mtimes filesTaylor Blau, Mar 2, 2022
  56. 07/17 builtin/pack-objects.c: return from create_object_entry()Taylor Blau, Mar 2, 2022
  57. 08/17 builtin/pack-objects.c: --cruft without expirationTaylor Blau, Mar 2, 2022
  58. 09/17 reachable: add options to add_unseen_recent_objects_to_traversalTaylor Blau, Mar 2, 2022
  59. Derrick StoleeMar 2, 2022
  60. Taylor BlauMar 2, 2022
  61. 11/17 builtin/pack-objects.c: --cruft with expirationTaylor Blau, Mar 2, 2022
  62. Junio C HamanoMar 2, 2022
  63. Taylor BlauMar 2, 2022
  64. Derrick StoleeMar 2, 2022
  65. 10/17 reachable: report precise timestamps from objects in cruft packsTaylor Blau, Mar 2, 2022
  66. 13/17 builtin/repack.c: allow configuring cruft pack generationTaylor Blau, Mar 2, 2022
  67. 12/17 builtin/repack.c: support generating a cruft packTaylor Blau, Mar 2, 2022
  68. 14/17 builtin/repack.c: use named flags for existing_packsTaylor Blau, Mar 2, 2022
  69. 15/17 builtin/repack.c: add cruft packs to MIDX during geometric repackTaylor Blau, Mar 2, 2022
  70. 16/17 builtin/gc.c: conditionally avoid pruning objects via looseTaylor Blau, Mar 2, 2022
  71. 17/17 sha1-file.c: don't freshen cruft packsTaylor Blau, Mar 2, 2022
  72. Derrick StoleeMar 2, 2022
  73. Taylor BlauMar 2, 2022
  74. 00/17 cruft packsTaylor Blau, Mar 3, 2022
  75. 01/17 Documentation/technical: add cruft-packs.txtTaylor Blau, Mar 3, 2022
  76. Jonathan NiederMar 7, 2022
  77. Taylor BlauMar 22, 2022
  78. Jonathan NiederMar 22, 2022
  79. Taylor BlauMar 22, 2022
  80. Jonathan NiederMar 22, 2022
  81. Taylor BlauMar 23, 2022
  82. Taylor BlauMar 28, 2022
  83. Junio C HamanoMar 28, 2022
  84. Taylor BlauMar 28, 2022
  85. Junio C HamanoMar 29, 2022
  86. Taylor BlauMar 30, 2022
  87. Junio C HamanoMar 30, 2022
  88. Taylor BlauMar 30, 2022
  89. 03/17 pack-write: pass 'struct packing_data' to 'stage_tmp_packfiles'Taylor Blau, Mar 3, 2022
  90. 02/17 pack-mtimes: support reading .mtimes filesTaylor Blau, Mar 3, 2022
  91. 04/17 chunk-format.h: extract oid_version()Taylor Blau, Mar 3, 2022
  92. Ævar Arnfjörð BjarmasonMar 3, 2022
  93. Taylor BlauMar 3, 2022
  94. Junio C HamanoMar 4, 2022
  95. 05/17 pack-mtimes: support writing pack .mtimes filesTaylor Blau, Mar 3, 2022
  96. Ævar Arnfjörð BjarmasonMar 3, 2022
  97. Taylor BlauMar 3, 2022
  98. Ævar Arnfjörð BjarmasonMar 4, 2022
  99. 06/17 t/helper: add 'pack-mtimes' test-toolTaylor Blau, Mar 3, 2022
  100. 07/17 builtin/pack-objects.c: return from create_object_entry()Taylor Blau, Mar 3, 2022
  101. 08/17 builtin/pack-objects.c: --cruft without expirationTaylor Blau, Mar 3, 2022
  102. 09/17 reachable: add options to add_unseen_recent_objects_to_traversalTaylor Blau, Mar 3, 2022
  103. 10/17 reachable: report precise timestamps from objects in cruft packsTaylor Blau, Mar 3, 2022
  104. 11/17 builtin/pack-objects.c: --cruft with expirationTaylor Blau, Mar 3, 2022
  105. 12/17 builtin/repack.c: support generating a cruft packTaylor Blau, Mar 3, 2022
  106. 13/17 builtin/repack.c: allow configuring cruft pack generationTaylor Blau, Mar 3, 2022
  107. 14/17 builtin/repack.c: use named flags for existing_packsTaylor Blau, Mar 3, 2022
  108. 16/17 builtin/gc.c: conditionally avoid pruning objects via looseTaylor Blau, Mar 3, 2022
  109. 17/17 sha1-file.c: don't freshen cruft packsTaylor Blau, Mar 3, 2022
  110. 15/17 builtin/repack.c: add cruft packs to MIDX during geometric repackTaylor Blau, Mar 3, 2022
  111. Derrick StoleeMar 3, 2022
  112. 00/17 cruft packsTaylor Blau, May 18, 2022
  113. 01/17 Documentation/technical: add cruft-packs.txtTaylor Blau, May 18, 2022
  114. Junio C HamanoMay 19, 2022
  115. 02/17 pack-mtimes: support reading .mtimes filesTaylor Blau, May 18, 2022
  116. Ævar Arnfjörð BjarmasonMay 19, 2022
  117. Junio C HamanoMay 19, 2022
  118. Ævar Arnfjörð BjarmasonMay 20, 2022
  119. Taylor BlauMay 20, 2022
  120. 03/17 pack-write: pass 'struct packing_data' to 'stage_tmp_packfiles'Taylor Blau, May 18, 2022
  121. 06/17 t/helper: add 'pack-mtimes' test-toolTaylor Blau, May 18, 2022
  122. 07/17 builtin/pack-objects.c: return from create_object_entry()Taylor Blau, May 18, 2022
  123. 10/17 reachable: report precise timestamps from objects in cruft packsTaylor Blau, May 18, 2022
  124. 09/17 reachable: add options to add_unseen_recent_objects_to_traversalTaylor Blau, May 18, 2022
  125. 08/17 builtin/pack-objects.c: --cruft without expirationTaylor Blau, May 18, 2022
  126. Junio C HamanoMay 19, 2022
  127. Junio C HamanoMay 19, 2022
  128. Taylor BlauMay 20, 2022
  129. 11/17 builtin/pack-objects.c: --cruft with expirationTaylor Blau, May 18, 2022
  130. 12/17 builtin/repack.c: support generating a cruft packTaylor Blau, May 18, 2022
  131. Ævar Arnfjörð BjarmasonMay 19, 2022
  132. Taylor BlauMay 20, 2022
  133. 04/17 chunk-format.h: extract oid_version()Taylor Blau, May 18, 2022
  134. Ævar Arnfjörð BjarmasonMay 19, 2022
  135. 05/17 pack-mtimes: support writing pack .mtimes filesTaylor Blau, May 18, 2022
  136. 13/17 builtin/repack.c: allow configuring cruft pack generationTaylor Blau, May 18, 2022
  137. 14/17 builtin/repack.c: use named flags for existing_packsTaylor Blau, May 18, 2022
  138. 15/17 builtin/repack.c: add cruft packs to MIDX during geometric repackTaylor Blau, May 18, 2022
  139. Ævar Arnfjörð BjarmasonMay 19, 2022
  140. Taylor BlauMay 20, 2022
  141. 16/17 builtin/gc.c: conditionally avoid pruning objects via looseTaylor Blau, May 18, 2022
  142. 17/17 sha1-file.c: don't freshen cruft packsTaylor Blau, May 18, 2022
  143. Derrick StoleeMay 18, 2022
  144. Junio C HamanoMay 20, 2022
  145. Taylor BlauMay 20, 2022
  146. 0/2 Utility functions for duplicated pack(write) codeÆvar Arnfjörð Bjarmason, May 19, 2022
  147. 1/2 packfile API: add and use a pack_name_to_ext() utility functionÆvar Arnfjörð Bjarmason, May 19, 2022
  148. Junio C HamanoMay 19, 2022
  149. 2/2 hash API: add and use a hash_short_id_by_algo() functionÆvar Arnfjörð Bjarmason, May 19, 2022
  150. Junio C HamanoMay 19, 2022
  151. Ævar Arnfjörð BjarmasonMay 19, 2022
  152. Junio C HamanoMay 19, 2022
  153. Ævar Arnfjörð BjarmasonMay 19, 2022
  154. 00/17 cruft packsTaylor Blau, May 20, 2022
  155. 01/17 Documentation/technical: add cruft-packs.txtTaylor Blau, May 20, 2022
  156. 05/17 pack-mtimes: support writing pack .mtimes filesTaylor Blau, May 20, 2022
  157. 04/17 chunk-format.h: extract oid_version()Taylor Blau, May 20, 2022
  158. 03/17 pack-write: pass 'struct packing_data' to 'stage_tmp_packfiles'Taylor Blau, May 20, 2022
  159. 06/17 t/helper: add 'pack-mtimes' test-toolTaylor Blau, May 20, 2022
  160. 07/17 builtin/pack-objects.c: return from create_object_entry()Taylor Blau, May 20, 2022
  161. 02/17 pack-mtimes: support reading .mtimes filesTaylor Blau, May 20, 2022
  162. Jonathan NiederMay 24, 2022
  163. rsbecker@nexbridge.comMay 24, 2022
  164. Taylor BlauMay 24, 2022
  165. rsbecker@nexbridge.comMay 24, 2022
  166. Taylor BlauMay 25, 2022
  167. rsbecker@nexbridge.comMay 25, 2022
  168. adding new 32-bit on-disk (unsigned) timestamp formats (was: [PATCH v5 02/17] pack-mtimes: support reading .mtimes files)Ævar Arnfjörð Bjarmason, May 25, 2022
  169. Derrick StoleeMay 25, 2022
  170. Taylor BlauMay 25, 2022
  171. Ævar Arnfjörð BjarmasonMay 26, 2022
  172. Taylor BlauMay 26, 2022
  173. Taylor BlauMay 24, 2022
  174. Jonathan NiederMay 25, 2022
  175. Taylor BlauMay 25, 2022
  176. rsbecker@nexbridge.comMay 25, 2022
  177. Taylor BlauMay 25, 2022
  178. Taylor BlauMay 25, 2022
  179. Junio C HamanoMay 26, 2022
  180. Andreas SchwabJun 1, 2023
  181. 08/17 builtin/pack-objects.c: --cruft without expirationTaylor Blau, May 20, 2022
  182. 10/17 reachable: report precise timestamps from objects in cruft packsTaylor Blau, May 20, 2022
  183. 09/17 reachable: add options to add_unseen_recent_objects_to_traversalTaylor Blau, May 20, 2022
  184. 11/17 builtin/pack-objects.c: --cruft with expirationTaylor Blau, May 20, 2022
  185. 12/17 builtin/repack.c: support generating a cruft packTaylor Blau, May 20, 2022
  186. 13/17 builtin/repack.c: allow configuring cruft pack generationTaylor Blau, May 20, 2022
  187. 15/17 builtin/repack.c: add cruft packs to MIDX during geometric repackTaylor Blau, May 20, 2022
  188. 14/17 builtin/repack.c: use named flags for existing_packsTaylor Blau, May 20, 2022
  189. 17/17 sha1-file.c: don't freshen cruft packsTaylor Blau, May 20, 2022
  190. 16/17 builtin/gc.c: conditionally avoid pruning objects via looseTaylor Blau, May 20, 2022
  191. René ScharfeJun 19, 2022
  192. Junio C HamanoJun 21, 2022
  193. Ævar Arnfjörð BjarmasonMay 21, 2022
  194. Jonathan NiederMay 24, 2022
  195. Taylor BlauMay 24, 2022
  196. Ævar Arnfjörð BjarmasonMay 24, 2022
  197. Taylor BlauMay 24, 2022
  198. Jonathan NiederMay 25, 2022
  199. Derrick StoleeMay 25, 2022
  200. Taylor BlauMay 25, 2022
  201. Ævar Arnfjörð BjarmasonMay 26, 2022

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.