You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This line in the lfs/pointer_clean.gocopyToTemp function causes the entire file to be read in to memory:
by, rerr := ioutil.ReadAll(buf)
For large files this can cause the process to consume an enormous amount of memory. In fact, on my particular system (Mac OS X), adding half a dozen 4-6 GB files caused it to run out of memory because it couldn't add more swap space because it had filled up the disk (the disk was quite full already).
I ended up having to git add files one at a time. It seems like adding multiple files at once compounds the problem.
This really needs to be re-written so that it doesn't require the entire file to be in memory. From my simple reading of the code, I can't see any reason why it needs to do this, and if it truly does, mmap()ing the file is probably a much better idea.
Hi @johnepinterest, thanks for opening this. What you're pointing out is my fault, and definitely a regression. Sorry about that.
The reason that we read from the buffer is to check if the contents of the file is already an LFS pointer, which we should write back to Git directly if asking to be cleaned during a check-in. Prior to LFS v1.5.4, the amount of data that was buffered was limited at blobSizeCutoff, which is 512 bytes (see: lfs/pointer.go at v1.5.3).
Behavior was added in v1.5.4 to enable LFS to stream the entire contents of a malformed pointer during checkouts. However, it looks like I forgot to cap the amount of data read from the buf, as you pointed out in the line above. Luckily, this only has measurable impact against large malformed pointers. Going forward, I think the following patch can safely be applied, and should be released as v1.5.5.
Activity
ttaylorr commentedon Jan 11, 2017
Hi @johnepinterest, thanks for opening this. What you're pointing out is my fault, and definitely a regression. Sorry about that.
The reason that we read from the buffer is to check if the contents of the file is already an LFS pointer, which we should write back to Git directly if asking to be cleaned during a check-in. Prior to LFS v1.5.4, the amount of data that was buffered was limited at
blobSizeCutoff, which is 512 bytes (see: lfs/pointer.go at v1.5.3).Behavior was added in v1.5.4 to enable LFS to stream the entire contents of a malformed pointer during checkouts. However, it looks like I forgot to cap the amount of data read from the
buf, as you pointed out in the line above. Luckily, this only has measurable impact against large malformed pointers. Going forward, I think the following patch can safely be applied, and should be released as v1.5.5.ttaylorr commentedon Jan 12, 2017
I went ahead and applied the above patch in #1852, which is open for review.
ttaylorr commentedon Jan 12, 2017
Git LFS v1.5.5 has been released which resolves this issue. Thanks again!