Skip to content

Stream packs to the destination#2004

Merged
vmg merged 3 commits into
libgit2:developmentfrom
ethomson:pack_stream
Jan 14, 2014
Merged

Stream packs to the destination#2004
vmg merged 3 commits into
libgit2:developmentfrom
ethomson:pack_stream

Conversation

@ethomson

Copy link
Copy Markdown
Member

Streaming the pack through to the target may be preferable to compressing fully in-memory and then splatting it out to the target. (I was OOM'ing while pushing very large commits with very large blobs.)

This introduces some simple helper functions to wrap zlib to deal with error handling and to expose a more write(2) like semantic.

@ethomson

Copy link
Copy Markdown
Member Author

I suspect there are other places that could be changed from doing a one-shot compression to using a streaming compressor, but I admit that I didn't look too carefully. This was really just to get over the hump of running out of memory so that I could continue to debug other issues.

I do have interest in looking closer at other zlib usages, but unfortunately I don't have the time to do that at present.

@arrbee

arrbee commented Dec 16, 2013

Copy link
Copy Markdown
Member

This looks really nice to me. The zstream stuff seems like a better abstraction level and I agree that we can look later at other places that can be improved similarly. I have a couple of questions:

  1. Do you think it is worth trying to avoid the repeated zbuf alloc/free inside write_object and move that temporary buffer into the packbuilder? Perhaps relative to everything else that has to be done, the allocation is too trivial to matter, but since it is a fixed size buffer, it seems like it could be allocated once and then just reused until we are done.
  2. Along those lines, is there any point in adding a git_zstream_reset function (that calls zlib's deflateReset function) so that we don't have to repeated recreate and free the zstream object? I don't know what the overhead is, but again it could be factored out if it made a performance difference.

Obviously both of those questions can be answered at a future point if you just want to get this in as an incremental improvement. The code looks good to me! 🤘

@ethomson

Copy link
Copy Markdown
Member Author

Yes, that definitely makes sense. Let's sit on this then until I have a few minutes to look at that.

@ethomson

ethomson commented Jan 7, 2014

Copy link
Copy Markdown
Member Author

Rebased and updated with @arrbee 's fine suggestions.

@ethomson

Copy link
Copy Markdown
Member Author

Rrrrrrebased! Any objections? If not, I shall merge this bad boy.

vmg pushed a commit that referenced this pull request Jan 14, 2014
Stream packs to the destination
@vmg vmg merged commit 0d5d0ea into libgit2:development Jan 14, 2014
@ethomson ethomson mentioned this pull request Jan 15, 2014
phatblat pushed a commit to phatblat/libgit2 that referenced this pull request Sep 13, 2014
@ethomson ethomson deleted the pack_stream branch February 5, 2015 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants