summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasaya Suzuki <masayasuzuki@google.com>2019-06-16 09:09:16 -0700
committerMasaya Suzuki <masayasuzuki@google.com>2019-08-12 10:34:24 -0700
commitc0cfdcd2f1a14eba2240ce26b3969b9e9267027d (patch)
tree81dbf7f12abc6594f7ada180a19b6999613a3e4a
parent46678b303c6625c039109b1a06c0df0ec82dd290 (diff)
downloadjgit-c0cfdcd2f1a14eba2240ce26b3969b9e9267027d.tar.gz
jgit-c0cfdcd2f1a14eba2240ce26b3969b9e9267027d.zip
dfs: Take size as long instead of int
Practically we wouldn't have 2GB+ objects in the DfsBlockCache, but by making it long, we can clean up some long-to-integer conversions. Change-Id: I1217f5f273a1420d80e2307ac9ff4a52460237a2 Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java14
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java20
2 files changed, 19 insertions, 15 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java
index cd5ada64aa..16e7a0d537 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java
@@ -449,7 +449,7 @@ public final class DfsBlockCache {
}
@SuppressWarnings("unchecked")
- private void reserveSpace(int reserve, DfsStreamKey key) {
+ private void reserveSpace(long reserve, DfsStreamKey key) {
clockLock.lock();
try {
long live = LongStream.of(getCurrentSize()).sum() + reserve;
@@ -486,7 +486,7 @@ public final class DfsBlockCache {
}
}
- private void creditSpace(int credit, DfsStreamKey key) {
+ private void creditSpace(long credit, DfsStreamKey key) {
clockLock.lock();
try {
getStat(liveBytes, key).addAndGet(-credit);
@@ -496,7 +496,7 @@ public final class DfsBlockCache {
}
@SuppressWarnings("unchecked")
- private void addToClock(Ref ref, int credit) {
+ private void addToClock(Ref ref, long credit) {
clockLock.lock();
try {
if (credit != 0) {
@@ -576,10 +576,10 @@ public final class DfsBlockCache {
}
<T> Ref<T> putRef(DfsStreamKey key, long size, T v) {
- return put(key, 0, (int) Math.min(size, Integer.MAX_VALUE), v);
+ return put(key, 0, size, v);
}
- <T> Ref<T> put(DfsStreamKey key, long pos, int size, T v) {
+ <T> Ref<T> put(DfsStreamKey key, long pos, long size, T v) {
int slot = slot(key, pos);
HashEntry e1 = table.get(slot);
Ref<T> ref = scanRef(e1, key, pos);
@@ -722,12 +722,12 @@ public final class DfsBlockCache {
static final class Ref<T> {
final DfsStreamKey key;
final long position;
- final int size;
+ final long size;
volatile T value;
Ref next;
volatile boolean hot;
- Ref(DfsStreamKey key, long position, int size, T v) {
+ Ref(DfsStreamKey key, long position, long size, T v) {
this.key = key;
this.position = position;
this.size = size;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
index bca891a522..6c69019e03 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
@@ -1035,12 +1035,13 @@ public final class DfsPackFile extends BlockBasedFile {
bs = wantSize;
}
PackIndex idx = PackIndex.read(new BufferedInputStream(in, bs));
- int sz = (int) Math.min(
- idx.getObjectCount() * REC_SIZE,
- Integer.MAX_VALUE);
ctx.stats.readIdxBytes += rc.position();
index = idx;
- return new DfsBlockCache.Ref<>(idxKey, REF_POSITION, sz, idx);
+ return new DfsBlockCache.Ref<>(
+ idxKey,
+ REF_POSITION,
+ idx.getObjectCount() * REC_SIZE,
+ idx);
} finally {
ctx.stats.readIdxMicros += elapsedMicros(start);
}
@@ -1058,9 +1059,12 @@ public final class DfsPackFile extends BlockBasedFile {
private DfsBlockCache.Ref<PackReverseIndex> loadReverseIdx(
DfsReader ctx, DfsStreamKey revKey, PackIndex idx) {
PackReverseIndex revidx = new PackReverseIndex(idx);
- int sz = (int) Math.min(idx.getObjectCount() * 8, Integer.MAX_VALUE);
reverseIndex = revidx;
- return new DfsBlockCache.Ref<>(revKey, REF_POSITION, sz, revidx);
+ return new DfsBlockCache.Ref<>(
+ revKey,
+ REF_POSITION,
+ idx.getObjectCount() * 8,
+ revidx);
}
private DfsBlockCache.Ref<PackBitmapIndex> loadBitmapIndex(
@@ -1089,9 +1093,9 @@ public final class DfsPackFile extends BlockBasedFile {
ctx.stats.readIdxBytes += size;
ctx.stats.readIdxMicros += elapsedMicros(start);
}
- int sz = (int) Math.min(size, Integer.MAX_VALUE);
bitmapIndex = bmidx;
- return new DfsBlockCache.Ref<>(bitmapKey, REF_POSITION, sz, bmidx);
+ return new DfsBlockCache.Ref<>(
+ bitmapKey, REF_POSITION, size, bmidx);
} catch (EOFException e) {
throw new IOException(MessageFormat.format(
DfsText.get().shortReadOfIndex,