Search in sources :

Example 1 with DefaultPageCursorTracer

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());
    }
}
Also used : DefaultPageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultPageCursorTracer

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;
}
Also used : DefaultPageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer)

Example 3 with DefaultPageCursorTracer

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DefaultPageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultPageCursorTracer

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"));
}
Also used : DefaultPageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DefaultPageCursorTracer (org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer)4 CursorContext (org.neo4j.io.pagecache.context.CursorContext)3 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)3 Test (org.junit.jupiter.api.Test)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1