use of org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer in project neo4j by neo4j.
the class KernelStatementTest method emptyPageCacheStatisticOnClosedStatement.
@Test
void emptyPageCacheStatisticOnClosedStatement() {
var transaction = mock(KernelTransactionImplementation.class, RETURNS_DEEP_STUBS);
try (var statement = createStatement(transaction)) {
var cursorContext = new CursorContext(new DefaultPageCursorTracer(new DefaultPageCacheTracer(), "test"));
statement.initialize(Mockito.mock(Locks.Client.class), cursorContext, 100);
statement.acquire();
cursorContext.getCursorTracer().beginPin(false, 1, null).hit();
cursorContext.getCursorTracer().beginPin(false, 1, null).hit();
cursorContext.getCursorTracer().beginPin(false, 1, null).beginPageFault(1, 2).done();
assertEquals(2, statement.getHits());
assertEquals(1, statement.getFaults());
statement.close();
assertEquals(0, statement.getHits());
assertEquals(0, statement.getFaults());
}
}
use of org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer in project neo4j by neo4j.
the class DefaultPageCursorTracerTest method createTracer.
private PageCursorTracer createTracer() {
DefaultPageCursorTracer pageCursorTracer = new DefaultPageCursorTracer();
pageCursorTracer.init(cacheTracer);
return pageCursorTracer;
}
use of org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer in project neo4j by neo4j.
the class PageCacheTest method tracerMustBeNotifiedOfReadAndWritePins.
@Test
void tracerMustBeNotifiedOfReadAndWritePins() throws Exception {
final AtomicInteger writeCount = new AtomicInteger();
final AtomicInteger readCount = new AtomicInteger();
DefaultPageCacheTracer tracer = new DefaultPageCacheTracer();
DefaultPageCursorTracer pageCursorTracer = new DefaultPageCursorTracer(tracer, "test") {
@Override
public PinEvent beginPin(boolean writeLock, long filePageId, PageSwapper swapper) {
(writeLock ? writeCount : readCount).getAndIncrement();
return super.beginPin(writeLock, filePageId, swapper);
}
};
getPageCache(fs, maxPages, tracer);
generateFileWithRecords(file("a"), recordCount, recordSize);
int pinsForRead = 13;
int pinsForWrite = 42;
try (PagedFile pagedFile = map(file("a"), filePageSize)) {
try (PageCursor cursor = pagedFile.io(0, PF_SHARED_READ_LOCK, new CursorContext(pageCursorTracer))) {
for (int i = 0; i < pinsForRead; i++) {
assertTrue(cursor.next());
}
}
dirtyManyPages(pagedFile, pinsForWrite, new CursorContext(pageCursorTracer));
}
assertThat(readCount.get()).as("wrong read pin count").isEqualTo(pinsForRead);
assertThat(writeCount.get()).as("wrong write pin count").isEqualTo(pinsForWrite);
}
use of org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer in project neo4j by neo4j.
the class PageCachePrefetchingTest method setUp.
@BeforeEach
void setUp() {
file = dir.createFile("file");
cursorContext = new CursorContext(new DefaultPageCursorTracer(new DefaultPageCacheTracer(), "test"));
}
Aggregations