]> source.dussan.org Git - jgit.git/commitdiff
GC: Trim EWAHCompressedBitmaps to free unused memory 48/125848/3
authorTerry Parker <tparker@google.com>
Tue, 10 Jul 2018 00:42:21 +0000 (17:42 -0700)
committerJonathan Nieder <jrn@google.com>
Tue, 10 Jul 2018 18:10:11 +0000 (14:10 -0400)
The "Building bitmaps" GC phase fails for large repositories (repos with
10M objects use 1.25MB per uncompressed bitmap, and those with long
histories may build >25k bitmaps). Since these bitmaps xor well against
each other, the actual space needed for each compressed bitmap is
usually no more than a few KB. Calling trim() will ensure we aren't
holding on to excess memory.

Change-Id: I40bf78c730b9f6051da6025f9777ce27220a5b0a
Signed-off-by: Terry Parker <tparker@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java

index 70eb10ea8f90185a2b854ba4a91e4bdac2274b25..eff7958748eed694fabfe8820362f6b209ff74b6 100644 (file)
@@ -351,6 +351,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
                                                PositionEntry entry = positionEntries.get(item);
                                                if (entry == null)
                                                        throw new IllegalStateException();
+                                               bestBitmap.trim();
                                                return new StoredEntry(entry.namePosition, bestBitmap,
                                                                bestXorOffset, item.getFlags());
                                        }
index c04c90f22f8ac63a07d205acf2b8f27692d5f7f1..70695880d3c3a2a6559575c5357a268743c62b82 100644 (file)
@@ -200,6 +200,7 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
                for (IntIterator i = oldBitmap.getBitmap().intIterator(); i.hasNext();)
                        inflated.set(prevToNewMapping[i.next()]);
                bitmap = inflated.toEWAHCompressedBitmap();
+               bitmap.trim();
                convertedBitmaps.add(
                                new StoredBitmap(objectId, bitmap, null, oldBitmap.getFlags()));
                return bitmap;