Skip to contentSkip to conversation

fast-import: Stream very large blobs directly to pack

PATCH New Shawn O. Pearce 1 participant 1 message Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 fast-import: Stream very large blobs directly to pack

If a blob is larger than the configured big-file-threshold, instead of reading it into a single buffer obtained from malloc, stream it onto the end of the current pack file. Streaming the larger objects into the pack avoids the 4+ GiB memory footprint that occurs when fast-import is processing 2+ GiB blobs.

---

Changed --big-file-threshold option to be in bytes. Squashed the documentation patch from earlier today.

 Documentation/config.txt          |   14 +++
 Documentation/git-fast-import.txt |    6 ++
 fast-import.c                     |  179 +++++++++++++++++++++++++++++++++----
 t/t5705-clone-2gb.sh              |    2 +-
 t/t9300-fast-import.sh            |   46 ++++++++++
 5 files changed, 227 insertions(+), 20 deletions(-)
Documentation/config.txt +14 -0
index f7728ec..b16a20b 100644
@@ -409,6 +409,20 @@ You probably do not need to adjust this value.
 +
 Common unit suffixes of 'k', 'm', or 'g' are supported.
 
+core.bigFileThreshold::
+	Files larger than this size are stored deflated, without
+	attempting delta compression.  Storing large files without
+	delta compression avoids excessive memory usage, at the
+	slight expense of increased disk usage.
++
+Default is 512 MiB on all platforms.  This should be reasonable
+for most projects as source code and other text files can still
+be delta compressed, but larger binary media files won't be.
++
+Common unit suffixes of 'k', 'm', or 'g' are supported.
++
+Currently only linkgit:git-fast-import[1] honors this setting.
+
 core.excludesfile::
 	In addition to '.gitignore' (per-directory) and
 	'.git/info/exclude', git looks into this file for patterns
Documentation/git-fast-import.txt +6 -0
index e6d364f..79c5f69 100644
@@ -50,6 +50,12 @@ OPTIONS
 	importers may wish to lower this, such as to ensure the
 	resulting packfiles fit on CDs.
 
+--big-file-threshold=<n>::
+	Maximum size of a blob that fast-import will attempt to
+	create a delta for, expressed in bytes.  The default is 512m
+	(512 MiB).  Some importers may wish to lower this on systems
+	with constrained memory.
+
 --depth=<n>::
 	Maximum delta depth, for blob and tree deltification.
 	Default is 10.
fast-import.c +160 -19

277 lines not on this page · raw message

t/t5705-clone-2gb.sh +1 -1
index 9f52154..adfaae8 100755
@@ -31,7 +31,7 @@ test_expect_success 'setup' '
 	 echo "data 5" &&
 	 echo ">2gb" &&
 	 cat commit) |
-	git fast-import &&
+	git fast-import --big-file-threshold=2 &&
 	test ! -f exit-status
 
 '
t/t9300-fast-import.sh +46 -0

50 lines not on this page · raw message

Signature · 4 lines
1.7.0.rc0.170.g7207c

-- 
Shawn.