Search in sources :

Example 71 with DefaultPageCacheTracer

use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.

the class NeoStoresIT method tracePageCacheAccessOnInUseCheck.

@Test
void tracePageCacheAccessOnInUseCheck() {
    var storageEngine = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class);
    var neoStores = storageEngine.testAccessNeoStores();
    var propertyStore = neoStores.getPropertyStore();
    try (Transaction transaction = db.beginTx()) {
        var node = transaction.createNode();
        node.setProperty("a", "b");
        transaction.commit();
    }
    var cursorContext = new CursorContext(new DefaultPageCacheTracer().createPageCursorTracer("tracePageCacheAccessOnInUseCheck"));
    propertyStore.isInUse(1L, cursorContext);
    PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
    assertEquals(1, cursorTracer.hits());
    assertEquals(1, cursorTracer.pins());
    assertEquals(1, cursorTracer.unpins());
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) Transaction(org.neo4j.graphdb.Transaction) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 72 with DefaultPageCacheTracer

use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.

the class NeoStoresIT method tracePageCacheAccessOnGetRecord.

@Test
void tracePageCacheAccessOnGetRecord() {
    var storageEngine = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class);
    var neoStores = storageEngine.testAccessNeoStores();
    var nodeStore = neoStores.getNodeStore();
    long nodeId;
    try (Transaction transaction = db.beginTx()) {
        var node = transaction.createNode();
        node.setProperty("a", "b");
        nodeId = node.getId();
        transaction.commit();
    }
    var cursorContext = new CursorContext(new DefaultPageCacheTracer().createPageCursorTracer("tracePageCacheAccessOnGetRecord"));
    nodeStore.getRecord(nodeId, new NodeRecord(nodeId), RecordLoad.NORMAL, cursorContext);
    PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
    assertEquals(1, cursorTracer.hits());
    assertEquals(1, cursorTracer.pins());
    assertEquals(1, cursorTracer.unpins());
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) Transaction(org.neo4j.graphdb.Transaction) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 73 with DefaultPageCacheTracer

use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.

the class IndexAccessorTests method dropShouldNotFlushContent.

@Test
void dropShouldNotFlushContent() throws IOException {
    // given
    accessor.close();
    DefaultPageCacheTracer tracer = new DefaultPageCacheTracer();
    try (PageCache pageCache = pageCacheExtension.getPageCache(fs, PageCacheConfig.config().withTracer(tracer))) {
        accessor = createAccessor(pageCache);
        long baseline = tracer.flushes();
        accessor.force(NULL);
        long preDrop = tracer.flushes();
        assertThat(preDrop).isGreaterThan(baseline);
        // when
        accessor.drop();
        // then
        long postDrop = tracer.flushes();
        assertEquals(preDrop, postDrop);
    }
}
Also used : PageCache(org.neo4j.io.pagecache.PageCache) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 74 with DefaultPageCacheTracer

use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.

the class MetaDataStoreTest method tracePageCacheAccessOnSetRecord.

@Test
void tracePageCacheAccessOnSetRecord() throws IOException {
    var cacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAccessOnSetRecord"));
    try (var metaDataStore = newMetaDataStore()) {
        MetaDataStore.setRecord(pageCache, metaDataStore.getStorageFile(), MetaDataStore.Position.RANDOM_NUMBER, 3, databaseLayout.getDatabaseName(), cursorContext);
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isOne();
        assertThat(cursorTracer.unpins()).isOne();
        assertThat(cursorTracer.hits()).isOne();
    }
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 75 with DefaultPageCacheTracer

use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.

the class MetaDataStoreTest method tracePageCacheAssessOnSetStoreId.

@Test
void tracePageCacheAssessOnSetStoreId() throws IOException {
    var cacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAssessOnSetStoreId"));
    try (var metaDataStore = newMetaDataStore()) {
        var storeId = new StoreId(1, 2, 3, 4, 5);
        MetaDataStore.setStoreId(pageCache, metaDataStore.getStorageFile(), storeId, 6, 7, databaseLayout.getDatabaseName(), cursorContext);
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(7);
        assertThat(cursorTracer.unpins()).isEqualTo(7);
        assertThat(cursorTracer.hits()).isEqualTo(7);
    }
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) ExternalStoreId(org.neo4j.storageengine.api.ExternalStoreId) StoreId(org.neo4j.storageengine.api.StoreId) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)79 Test (org.junit.jupiter.api.Test)66 CursorContext (org.neo4j.io.pagecache.context.CursorContext)49 PageCursorTracer (org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer)26 Path (java.nio.file.Path)11 RepeatedTest (org.junit.jupiter.api.RepeatedTest)10 MutableLong (org.apache.commons.lang3.mutable.MutableLong)9 Transaction (org.neo4j.graphdb.Transaction)9 PageCache (org.neo4j.io.pagecache.PageCache)9 Test (org.junit.Test)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 DelegatingPageCache (org.neo4j.io.pagecache.DelegatingPageCache)5 PagedFile (org.neo4j.io.pagecache.PagedFile)5 Config (org.neo4j.configuration.Config)3 PageCacheTest (org.neo4j.io.pagecache.PageCacheTest)3 PageCursor (org.neo4j.io.pagecache.PageCursor)3 PageCacheStressTest (org.neo4j.io.pagecache.stress.PageCacheStressTest)3 PageCacheTracer (org.neo4j.io.pagecache.tracing.PageCacheTracer)3 DefaultPageCursorTracer (org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer)3 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)3