use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class PageCacheTest method noFaultReadOfPagesNotInMemory.
@Test
void noFaultReadOfPagesNotInMemory() throws Exception {
DefaultPageCacheTracer cacheTracer = new DefaultPageCacheTracer();
getPageCache(fs, maxPages, cacheTracer);
Path file = file("a");
generateFileWithRecords(file, recordsPerFilePage * 2, recordSize);
long initialFaults = cacheTracer.faults();
try (PagedFile pf = map(file, filePageSize);
CursorContext cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("noFaultReadOfPagesNotInMemory"));
PageCursor nofault = pf.io(0, PF_SHARED_READ_LOCK | PF_NO_FAULT, cursorContext)) {
verifyNoFaultAccessToPagesNotInMemory(cacheTracer, cursorContext, nofault, initialFaults);
}
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class PageCacheTest method noFaultLinkedReadOfPagesNotInMemory.
@Test
void noFaultLinkedReadOfPagesNotInMemory() throws Exception {
DefaultPageCacheTracer cacheTracer = new DefaultPageCacheTracer();
getPageCache(fs, maxPages, cacheTracer);
Path file = file("a");
generateFileWithRecords(file, recordsPerFilePage * 2, recordSize);
long initialFaults = cacheTracer.faults();
try (PagedFile pf = map(file, filePageSize);
CursorContext cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("noFaultLinkedReadOfPagesNotInMemory"));
PageCursor nofault = pf.io(0, PF_SHARED_READ_LOCK | PF_NO_FAULT, cursorContext);
PageCursor linkedNoFault = nofault.openLinkedCursor(0)) {
verifyNoFaultAccessToPagesNotInMemory(cacheTracer, cursorContext, linkedNoFault, initialFaults);
}
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class PageCacheTest method pinEventShouldCompleteIfRepinFromShouldRetryThrows.
@Test
void pinEventShouldCompleteIfRepinFromShouldRetryThrows() throws IOException {
DefaultPageCacheTracer tracer = new DefaultPageCacheTracer();
RandomAdversary adversary = new RandomAdversary(0.0, 0.9, 0.0);
adversary.setProbabilityFactor(0.0);
AdversarialFileSystemAbstraction afs = new AdversarialFileSystemAbstraction(adversary, fs);
getPageCache(afs, maxPages, tracer);
generateFileWithRecords(file("a"), recordCount, recordSize);
try (PagedFile pagedFile = map(file("a"), filePageSize);
CursorContext cursorContext = new CursorContext(tracer.createPageCursorTracer("test"))) {
try (PageCursor reader = pagedFile.io(0, PF_SHARED_READ_LOCK, cursorContext)) {
assertTrue(reader.next());
// Cause the page under the reader cursor to be evicted.
try (PagedFile otherPagedFile = map(existingFile("b"), filePageSize)) {
assertThrows(IOException.class, () -> {
// noinspection InfiniteLoopStatement
for (; ; ) {
adversary.setProbabilityFactor(1.0);
try {
reader.shouldRetry();
} finally {
adversary.setProbabilityFactor(0.0);
}
try (PageCursor writer = otherPagedFile.io(0, PF_SHARED_WRITE_LOCK, cursorContext)) {
for (int i = 0; i < maxPages * 10; i++) {
assertTrue(writer.next(i));
}
}
otherPagedFile.flushAndForce();
}
});
}
}
}
// Then we should see pins and unpins pair up exactly.
assertThat(tracer.unpins()).isEqualTo(tracer.pins());
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class ReadOnlyLogVersionRepositoryIT method tracePageCacheAccessOnReadOnlyLogRepoConstruction.
@Test
void tracePageCacheAccessOnReadOnlyLogRepoConstruction() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnReadOnlyLogRepoConstruction"));
new ReadOnlyLogVersionRepository(pageCache, databaseLayout, cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(2);
assertThat(cursorTracer.unpins()).isEqualTo(2);
assertThat(cursorTracer.hits()).isEqualTo(2);
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class CommitProcessTracingIT method tracePageCacheAccessOnEmptyTransactionApply.
@Test
void tracePageCacheAccessOnEmptyTransactionApply() throws TransactionFailureException {
var transaction = new PhysicalTransactionRepresentation(emptyList(), EMPTY_BYTE_ARRAY, 0, 0, 0, 0, ANONYMOUS);
var pageCacheTracer = new DefaultPageCacheTracer();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnEmptyTransactionApply"))) {
assertZeroCursor(cursorContext);
commitProcess.commit(new TransactionToApply(transaction, cursorContext), NULL, EXTERNAL);
assertCursor(cursorContext, 2);
}
}
Aggregations