From 04b9f44367f578f66129ec58f09a448041feedc4 Mon Sep 17 00:00:00 2001 From: Terry Parker Date: Mon, 9 Jul 2018 17:42:21 -0700 Subject: [PATCH] GC: Trim EWAHCompressedBitmaps to free unused memory 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 --- .../jgit/internal/storage/file/PackBitmapIndexBuilder.java | 1 + .../jgit/internal/storage/file/PackBitmapIndexRemapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java index 70eb10ea8..eff795874 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java @@ -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()); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java index c04c90f22..70695880d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java @@ -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;