Avoid using a lot of memory when large objects are present in the git repository
authorJoey Hess <joeyh@joeyh.name>
Wed, 5 Oct 2016 19:21:36 +0000 (15:21 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 5 Oct 2016 19:24:13 +0000 (15:24 -0400)
commit34530e59d9a35e38343e9e6a622fe06e42121e54
treedf447a51964cfbf6826036c40d2882c370523953
parent672e53bded15ca5a6c26b1db324d1dcf9345f1bc
Avoid using a lot of memory when large objects are present in the git repository

.. and have to be checked to see if they are a pointed to an annexed file.

Cases where such memory use could occur included, but were not limited to:
  - git commit -a of a large unlocked file (in v5 mode)
  - git-annex adjust when a large file was checked into git directly
Generally, any use of catKey was a potential problem.

Fix by using git cat-file --batch-check to check size before catting.
This adds another git batch process, which is included in the CatFileHandle
for simplicity.

There could be performance impact, anywhere catKey is used. Particularly
likely to affect adjusted branch generation speed, and operations on
unlocked files in v6 mode. Hopefully since the --batch-check and
--batch read the same data, disk buffering will avoid most overhead.
Leaving only the overhead of talking to the process over the pipe and
whatever computation --batch-check needs to do.

This commit was sponsored by Bruno BEAUFILS on Patreon.
Annex/CatFile.hs
Annex/Link.hs
CHANGELOG
Git/CatFile.hs
doc/bugs/committing_an_edited_file_fails_with___34__hGetBuf__58___Invalid_argument__34__/comment_2_b436936c502a40c01f82e64d97f1875e._comment [new file with mode: 0644]