On a large repository [1] we observe that a gitiles GET request on a commit:
GET https:/.../plugins/gitiles/<repo-name>/+/<commit-id>
can cause memory allocation of >100GB when caches are cold.
And even when caches are not cold, this kind of request can often allocate >20GB.
For those having repositories of similar size: can you check if you have the same issue? Note that the allocated memory per request is available in the httpd_log so it should be easy to check.
We found that this is related to the gitiles' visibility check which ends-up reading the bitmap index.
Profiling JVM showed that this code-path a[2] allocated >100GB.
If we remove the bitmap index then with cold caches allocated memory for the same request goes around 400MB.
[1]
$ git count-objects -vHcount: 4347
size: 22.98 MiB
in-pack: 46628601
packs: 240
size-pack: 12.91 GiB
prune-packable: 106
garbage: 1
size-garbage: 0 bytes
$ git show-ref | wc -l
2830244
Stack Trace Count Percentage
void com.googlecode.javaewah.LongArray.<init>(int) 78464 99,8 %
void com.googlecode.javaewah.EWAHCompressedBitmap.<init>(int) 78462 99,8 %
EWAHCompressedBitmap com.googlecode.javaewah.EWAHCompressedBitmap.xor(EWAHCompressedBitmap) 78349 99,6 %
EWAHCompressedBitmap org.eclipse.jgit.internal.storage.file.BasePackBitmapIndex$StoredBitmap.getBitmapWithoutCaching() 78349 99,6 %
EWAHCompressedBitmap org.eclipse.jgit.internal.storage.file.BasePackBitmapIndex$StoredBitmap.getBitmap() 78349 99,6 %
EWAHCompressedBitmap org.eclipse.jgit.internal.storage.file.BasePackBitmapIndex.getBitmap(AnyObjectId) 78349 99,6 %
BitmapIndexImpl$CompressedBitmap org.eclipse.jgit.internal.storage.file.BitmapIndexImpl.getBitmap(AnyObjectId) 78349 99,6 %
BitmapIndex$Bitmap org.eclipse.jgit.internal.storage.file.BitmapIndexImpl.getBitmap(AnyObjectId) 78349 99,6 %
boolean org.eclipse.jgit.internal.revwalk.BitmappedReachabilityChecker$ReachedFilter.include(RevWalk, RevCommit) 78349 99,6 %
RevCommit org.eclipse.jgit.revwalk.PendingGenerator.next() 78349 99,6 %
void org.eclipse.jgit.revwalk.RewriteGenerator.applyFilterToParents(RevCommit) 77939 99,1 %
RevCommit org.eclipse.jgit.revwalk.RewriteGenerator.next() 77939 99,1 %
void org.eclipse.jgit.revwalk.TopoSortGenerator.<init>(Generator) 77939 99,1 %
RevCommit org.eclipse.jgit.revwalk.StartGenerator.next() 77939 99,1 %
RevCommit org.eclipse.jgit.revwalk.RevWalk.next() 77939 99,1 %
Optional org.eclipse.jgit.internal.revwalk.BitmappedReachabilityChecker.areAllReachable(Collection, Stream) 77939 99,1 %
Optional org.eclipse.jgit.revwalk.ReachabilityChecker.areAllReachable(Collection, Collection) 77939 99,1 %
boolean com.google.gitiles.VisibilityChecker.isReachableFrom(String, RevWalk, RevCommit, Collection) 77939 99,1 %
boolean com.google.gitiles.VisibilityCache.isReachableFrom(String, RevWalk, RevCommit, Stream) 77939 99,1 %
boolean com.google.gitiles.VisibilityCache.isReachableFromRefs(String, RevWalk, RevCommit, Stream) 77939 99,1 %
boolean com.google.gitiles.VisibilityCache.isVisible(Repository, RevWalk, ObjectId, Collection) 77939 99,1 %
...