Browse Source

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 <tparker@google.com>
stable-5.1
Terry Parker 6 years ago committed by Jonathan Nieder
parent
commit
04b9f44367
  1. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
  2. 1
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java

1
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); PositionEntry entry = positionEntries.get(item);
if (entry == null) if (entry == null)
throw new IllegalStateException(); throw new IllegalStateException();
bestBitmap.trim();
return new StoredEntry(entry.namePosition, bestBitmap, return new StoredEntry(entry.namePosition, bestBitmap,
bestXorOffset, item.getFlags()); bestXorOffset, item.getFlags());
} }

1
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();) for (IntIterator i = oldBitmap.getBitmap().intIterator(); i.hasNext();)
inflated.set(prevToNewMapping[i.next()]); inflated.set(prevToNewMapping[i.next()]);
bitmap = inflated.toEWAHCompressedBitmap(); bitmap = inflated.toEWAHCompressedBitmap();
bitmap.trim();
convertedBitmaps.add( convertedBitmaps.add(
new StoredBitmap(objectId, bitmap, null, oldBitmap.getFlags())); new StoredBitmap(objectId, bitmap, null, oldBitmap.getFlags()));
return bitmap; return bitmap;

Loading…
Cancel
Save