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

Re: [PATCH] pack-objects: use streaming interface for reading large loose blobs

From
Nicolas Pitre <nico@fluxnic.net>
Date
May 12, 2012, 16:51 UTC
Message-ID
<alpine.LFD.2.02.1205121220070.21030@xanadu.home>
In-Reply-To
<1336818375-16895-1-git-send-email-pclouds@gmail.com>
On Sat, 12 May 2012, Nguyễn Thái Ngọc Duy wrote:
Show 10 quoted lines
> git usually streams large blobs directly to packs. But there are cases
> where git can create large loose blobs (unpack-objects or hash-object
> over pipe). Or they can come from other git implementations.
> core.bigfilethreshold can also be lowered down and introduce a new
> wave of large loose blobs.
> 
> Use streaming interface to read these blobs and compress/write at the
> same time.
> 
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Comments below.
Show 21 quoted lines
> ---
>  index-pack's streaming support is on the way. unpack-objects is
>  another story because I'm thinking of merging it back to index-pack
>  first, which may take more than one release cycle.
> 
>  builtin/pack-objects.c |   73 ++++++++++++++++++++++++++++++++++++++++++++----
>  t/t1050-large.sh       |   16 ++++++++++
>  2 files changed, 83 insertions(+), 6 deletions(-)
> 
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index 1861093..98b51c1 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -259,9 +309,14 @@ static unsigned long write_object(struct sha1file *f,
>  	if (!to_reuse) {
>  		no_reuse:
>  		if (!usable_delta) {
> -			buf = read_sha1_file(entry->idx.sha1, &type, &size);
> -			if (!buf)
> -				die("unable to read %s", sha1_to_hex(entry->idx.sha1));
> +			type = sha1_object_info(entry->idx.sha1, &size);

Please don't use sha1_object_info() lightly. This is a potentially expensive operation, and you really don't want to do it on each objects.

And as a matter of fact, the information you are looking for has already been determined earlier. See the code in check_object() which tries hard to avoid sha1_object_info() as much as possible.

Therefore you should have entry->type and entry->size already set for you to use.

Nicolas
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 2 of 16 in “pack-objects: use streaming interface for reading large loose blobs”
  1. pack-objects: use streaming interface for reading large loose blobsNguyễn Thái Ngọc Duy, May 12, 2012
  2. Nicolas PitreMay 12, 2012
  3. pack-objects: use streaming interface for reading large loose blobsNguyễn Thái Ngọc Duy, May 13, 2012
  4. Junio C HamanoMay 14, 2012
  5. Junio C HamanoMay 14, 2012
  6. Nguyen Thai Ngoc DuyMay 15, 2012
  7. Junio C HamanoMay 15, 2012
  8. Nguyen Thai Ngoc DuyMay 16, 2012
  9. 1/4 streaming: allow to call close_istream(NULL);Nguyễn Thái Ngọc Duy, May 16, 2012
  10. 2/4 pack-objects, streaming: turn "xx >= big_file_threshold" to ".. > .."Nguyễn Thái Ngọc Duy, May 16, 2012
  11. Junio C HamanoMay 18, 2012
  12. 3/4 pack-objects: refactor write_object()Nguyễn Thái Ngọc Duy, May 16, 2012
  13. Junio C HamanoMay 18, 2012
  14. Nicolas PitreMay 19, 2012
  15. 4/4 pack-objects: use streaming interface for reading large loose blobsNguyễn Thái Ngọc Duy, May 16, 2012
  16. Junio C HamanoMay 18, 2012

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.