diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-07-02 12:41:39 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-07-02 12:41:39 -0700 |
commit | 113577617bc4b2b31f2a44290cc607431c8357a7 (patch) | |
tree | 870f1bfcf97561be8e71220266996a21e9a3de01 /org.eclipse.jgit.test/tst | |
parent | ad68553be4417ec7ac636c3d823fdddced46ecfb (diff) | |
download | jgit-113577617bc4b2b31f2a44290cc607431c8357a7.tar.gz jgit-113577617bc4b2b31f2a44290cc607431c8357a7.zip |
Use core.streamFileThreshold to set our streaming limit
We default this to 1 MiB for now, but we allow users to modify
it through the Repository's configuration file to be a different
value. A new repository listener is used to identify when the
setting has been updated and trigger a reconfiguration of any
active ObjectReaders.
To prevent a horrible explosion we cap core.streamFileThreshold
at no more than 1/4 of the maximum JVM heap size. We do this
because we need at least 2 byte arrays equal in size to the
stream threshold for the worst case delta inflation scenario,
and our host application probably also needs some amount of the
heap for their working set size.
Change-Id: I103b3a541dc970bbf1a6d92917a12c5a1ee34d6c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackFileTest.java | 8 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackFileTest.java index 1b6e3bff95..1a40b8e79c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackFileTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackFileTest.java @@ -118,7 +118,7 @@ public class PackFileTest extends LocalDiskRepositoryTestCase { public void testWhole_LargeObject() throws Exception { final int type = Constants.OBJ_BLOB; - byte[] data = rng.nextBytes(UnpackedObject.LARGE_OBJECT + 5); + byte[] data = rng.nextBytes(ObjectLoader.STREAM_THRESHOLD + 5); RevBlob id = tr.blob(data); tr.branch("master").commit().add("A", id).create(); tr.packAndPrune(); @@ -209,7 +209,7 @@ public class PackFileTest extends LocalDiskRepositoryTestCase { public void testDelta_LargeObjectChain() throws Exception { ObjectInserter.Formatter fmt = new ObjectInserter.Formatter(); - byte[] data0 = new byte[UnpackedObject.LARGE_OBJECT + 5]; + byte[] data0 = new byte[ObjectLoader.STREAM_THRESHOLD + 5]; Arrays.fill(data0, (byte) 0xf3); ObjectId id0 = fmt.idFor(Constants.OBJ_BLOB, data0); @@ -277,12 +277,12 @@ public class PackFileTest extends LocalDiskRepositoryTestCase { Arrays.fill(data0, (byte) 0xf3); ObjectId id0 = fmt.idFor(Constants.OBJ_BLOB, data0); - byte[] data3 = rng.nextBytes(UnpackedObject.LARGE_OBJECT + 5); + byte[] data3 = rng.nextBytes(ObjectLoader.STREAM_THRESHOLD + 5); ByteArrayOutputStream tmp = new ByteArrayOutputStream(); DeltaEncoder de = new DeltaEncoder(tmp, data0.length, data3.length); de.insert(data3, 0, data3.length); byte[] delta3 = tmp.toByteArray(); - assertTrue(delta3.length > UnpackedObject.LARGE_OBJECT); + assertTrue(delta3.length > ObjectLoader.STREAM_THRESHOLD); TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(64 * 1024); packHeader(pack, 2); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java index 4ca64d3eba..d77a962209 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/UnpackedObjectTest.java @@ -113,7 +113,7 @@ public class UnpackedObjectTest extends LocalDiskRepositoryTestCase { public void testStandardFormat_LargeObject() throws Exception { final int type = Constants.OBJ_BLOB; - byte[] data = rng.nextBytes(UnpackedObject.LARGE_OBJECT + 5); + byte[] data = rng.nextBytes(ObjectLoader.STREAM_THRESHOLD + 5); ObjectId id = new ObjectInserter.Formatter().idFor(type, data); write(id, compressStandardFormat(type, data)); @@ -230,7 +230,7 @@ public class UnpackedObjectTest extends LocalDiskRepositoryTestCase { public void testStandardFormat_LargeObject_CorruptZLibStream() throws Exception { final int type = Constants.OBJ_BLOB; - byte[] data = rng.nextBytes(UnpackedObject.LARGE_OBJECT + 5); + byte[] data = rng.nextBytes(ObjectLoader.STREAM_THRESHOLD + 5); ObjectId id = new ObjectInserter.Formatter().idFor(type, data); byte[] gz = compressStandardFormat(type, data); gz[gz.length - 1] = 0; @@ -290,7 +290,7 @@ public class UnpackedObjectTest extends LocalDiskRepositoryTestCase { public void testPackFormat_LargeObject() throws Exception { final int type = Constants.OBJ_BLOB; - byte[] data = rng.nextBytes(UnpackedObject.LARGE_OBJECT + 5); + byte[] data = rng.nextBytes(ObjectLoader.STREAM_THRESHOLD + 5); ObjectId id = new ObjectInserter.Formatter().idFor(type, data); write(id, compressPackFormat(type, data)); |