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

Re: git --archive

From
René Scharfe <l.s.r@web.de>
Date
Sep 24, 2022, 13:19 UTC
Message-ID
<712ffe78-c3e3-dacf-c3e3-f339385e9bb4@web.de>
In-Reply-To
<PH0PR06MB7639DAA5CA112495E3EB43AB86509@PH0PR06MB7639.namprd06.prod.outlook.com>
Am 24.09.22 um 13:34 schrieb Scheffenegger, Richard:
Show 11 quoted lines
>
>> If I/O latency instead of CPU usage is the limiting factor and
>> prefetching would help then starting git grep or git archive in the
>> background might work.  If the order of visited blobs needs to be
>> randomized then perhaps something like this would be better:
>>
>> git ls-tree -r HEAD | awk '{print $3}' | sort | git cat-file
>> --batch >/dev/null
>
> Isn't the 2nd git, receiving input from stdin, running
> single-threaded?
Yes.
Show 7 quoted lines
> Maybe
>
> Git ls-tree -r HEAD | awk '{print $3}' | sort | split -d -l 100 -a 4
> - splitted ; for i in $(ls splitted????) ; do "git cat-file --batch >
> /dev/null &"; done; rm -f splitted????
>
> To parallelize the reading of the objects?

Sure, but in a repository with 100000 files you'd end up with 1000 parallel processes, which may be a few too many. Splitting the list into similar-sized parts based on a given degree of parallelism is probably more practical.

It could be done by relying on the randomness of the object IDs and partitioning by a sub-string. Or perhaps using pseudo-random numbers is sufficient:

   git ls-tree -r HEAD |
   awk '{print $3}' |
   sort |
   awk -v pieces=8 -v prefix=file '
      {
         piece = int(rand() * pieces)
         filename = prefix piece
         print $0 > filename
      }'
So how much does such a warmup help in your case?
>> No idea how to randomize the order of tree object visits.
>
> To heat up data caches, the order of objects visited is not relevant,
> the order or IOs issued to the actual object is relevant.
What's the difference?
NB: When I wrote "tree objects" I meant the type of objects from Git's
object store (made up of packs and loose files) that represent
sub-directories, and with "visit" I meant reading them to traverse the
hierarchy of Git blobs and trees.

Here's an idea after all: Using "git ls-tree" without "-r" and handling recursing in the prefetch script would allow traversing trees in a different order and even in parallel. Not sure how to limit parallelism to a sane degree.

René
Previous: Scheffenegger, RichardNext: René Scharfe
Message 9 of 12 in “git --archive”
  1. Scheffenegger, RichardSep 22, 2022
  2. Junio C HamanoSep 22, 2022
  3. Scheffenegger, RichardSep 22, 2022
  4. brian m. carlsonSep 23, 2022
  5. Junio C HamanoSep 23, 2022
  6. Scheffenegger, RichardSep 23, 2022
  7. René ScharfeSep 24, 2022
  8. Scheffenegger, RichardSep 24, 2022
  9. René ScharfeSep 24, 2022
  10. René ScharfeSep 24, 2022
  11. René ScharfeSep 25, 2022
  12. Scheffenegger, RichardSep 24, 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.