DfsStreamKey: Replace ForReverseIndex to separate metrics.
Keys used for identifying reverse indexes in the DfsBlockCache use a custom subclass ForReverseIndex because there was no PackExt for them. This conflates BlockCacheMetrics for reverse indexes with those for packs, since the key falls back onto 0 when there is no extension. Replace the custom ForReverseIndex with a DfsStreamKey usage to bring keys for the new REVERSE_INDEX extension in line with INDEX and BITMAP and separate reverse index and pack BlockCacheMetrics. Change-Id: I305e2c16d2a8cb2a824855ea92e0c9a9b188fce5 Signed-off-by: Anna Papitto <annapapitto@google.com>
This commit is contained in:
parent
5c033a98f6
commit
accacc27a1
|
@ -289,8 +289,7 @@ public void noConcurrencySerializedReads_oneRepo() throws Exception {
|
|||
|
||||
assertEquals(1, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]);
|
||||
assertEquals(1, cache.getMissCount()[PackExt.INDEX.ordinal()]);
|
||||
// Reverse index has no pack extension, it defaults to 0.
|
||||
assertEquals(1, cache.getMissCount()[0]);
|
||||
assertEquals(1, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
|
@ -319,7 +318,7 @@ public void noConcurrencySerializedReads_twoRepos() throws Exception {
|
|||
waitForExecutorPoolTermination();
|
||||
assertEquals(2, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]);
|
||||
assertEquals(2, cache.getMissCount()[PackExt.INDEX.ordinal()]);
|
||||
assertEquals(2, cache.getMissCount()[0]);
|
||||
assertEquals(2, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
|
@ -348,7 +347,7 @@ public void lowConcurrencyParallelReads_twoRepos() throws Exception {
|
|||
waitForExecutorPoolTermination();
|
||||
assertEquals(2, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]);
|
||||
assertEquals(2, cache.getMissCount()[PackExt.INDEX.ordinal()]);
|
||||
assertEquals(2, cache.getMissCount()[0]);
|
||||
assertEquals(2, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
|
@ -380,7 +379,7 @@ public void lowConcurrencyParallelReads_twoReposAndIndex()
|
|||
assertEquals(2, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]);
|
||||
// Index is loaded once for each repo.
|
||||
assertEquals(2, cache.getMissCount()[PackExt.INDEX.ordinal()]);
|
||||
assertEquals(2, cache.getMissCount()[0]);
|
||||
assertEquals(2, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -402,7 +401,7 @@ public void highConcurrencyParallelReads_oneRepo() throws Exception {
|
|||
|
||||
assertEquals(1, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]);
|
||||
assertEquals(1, cache.getMissCount()[PackExt.INDEX.ordinal()]);
|
||||
assertEquals(1, cache.getMissCount()[0]);
|
||||
assertEquals(1, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -426,7 +425,7 @@ public void highConcurrencyParallelReads_oneRepoParallelReverseIndex()
|
|||
|
||||
assertEquals(1, cache.getMissCount()[PackExt.BITMAP_INDEX.ordinal()]);
|
||||
assertEquals(1, cache.getMissCount()[PackExt.INDEX.ordinal()]);
|
||||
assertEquals(1, cache.getMissCount()[0]);
|
||||
assertEquals(1, cache.getMissCount()[PackExt.REVERSE_INDEX.ordinal()]);
|
||||
}
|
||||
|
||||
private void resetCache() {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import static org.eclipse.jgit.internal.storage.pack.PackExt.BITMAP_INDEX;
|
||||
import static org.eclipse.jgit.internal.storage.pack.PackExt.INDEX;
|
||||
import static org.eclipse.jgit.internal.storage.pack.PackExt.PACK;
|
||||
import static org.eclipse.jgit.internal.storage.pack.PackExt.REVERSE_INDEX;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.EOFException;
|
||||
|
@ -220,8 +221,7 @@ PackReverseIndex getReverseIdx(DfsReader ctx) throws IOException {
|
|||
}
|
||||
|
||||
PackIndex idx = idx(ctx);
|
||||
DfsStreamKey revKey = new DfsStreamKey.ForReverseIndex(
|
||||
desc.getStreamKey(INDEX));
|
||||
DfsStreamKey revKey = desc.getStreamKey(REVERSE_INDEX);
|
||||
AtomicBoolean cacheHit = new AtomicBoolean(true);
|
||||
DfsBlockCache.Ref<PackReverseIndex> revref = cache.getOrLoadRef(revKey,
|
||||
REF_POSITION, () -> {
|
||||
|
|
|
@ -95,19 +95,4 @@ public boolean equals(Object o) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static final class ForReverseIndex extends DfsStreamKey {
|
||||
private final DfsStreamKey idxKey;
|
||||
|
||||
ForReverseIndex(DfsStreamKey idxKey) {
|
||||
super(idxKey.hash + 1, null);
|
||||
this.idxKey = idxKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ForReverseIndex
|
||||
&& idxKey.equals(((ForReverseIndex) o).idxKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue