Search in sources :

Example 26 with PageCursorTracer

use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.

the class ReadOnlyTransactionIdStoreIT method testPageCacheAccessOnTransactionIdStoreConstruction.

@Test
void testPageCacheAccessOnTransactionIdStoreConstruction() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("testPageCacheAccessOnTransactionIdStoreConstruction"));
    new ReadOnlyTransactionIdStore(fs, pageCache, databaseLayout, cursorContext);
    PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
    assertThat(cursorTracer.pins()).isEqualTo(4);
    assertThat(cursorTracer.unpins()).isEqualTo(4);
    assertThat(cursorTracer.hits()).isEqualTo(4);
}
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 27 with PageCursorTracer

use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.

the class TxStateTransactionDataSnapshotIT method assertZeroTracer.

private void assertZeroTracer(CursorContext cursorContext) {
    PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
    assertThat(cursorTracer.pins()).isZero();
    assertThat(cursorTracer.hits()).isZero();
    assertThat(cursorTracer.unpins()).isZero();
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer)

Example 28 with PageCursorTracer

use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.

the class CountsComputerTest method tracePageCacheAccessOnInitialization.

@Test
void tracePageCacheAccessOnInitialization() throws IOException {
    DatabaseManagementService managementService = dbBuilder.build();
    try {
        GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
        var countsStore = db.getDependencyResolver().resolveDependency(GBPTreeCountsStore.class);
        var pageCacheTracer = new DefaultPageCacheTracer();
        var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnInitialization"));
        countsStore.start(cursorContext, INSTANCE);
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        softly.assertThat(cursorTracer.pins()).as("Pins").isEqualTo(1);
        softly.assertThat(cursorTracer.unpins()).as("Unpins").isEqualTo(1);
        softly.assertThat(cursorTracer.hits()).as("hits").isEqualTo(1);
    } finally {
        managementService.shutdown();
    }
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 29 with PageCursorTracer

use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.

the class NodeEntityTest method traceNodePageCacheAccessOnRelationshipsAccess.

@Test
void traceNodePageCacheAccessOnRelationshipsAccess() {
    long targetId;
    var relationshipType = RelationshipType.withName("connection");
    try (Transaction tx = db.beginTx()) {
        var target = tx.createNode();
        for (int i = 0; i < 100; i++) {
            tx.createNode().createRelationshipTo(target, relationshipType);
        }
        targetId = target.getId();
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        var cursorContext = ((InternalTransaction) tx).kernelTransaction().cursorContext();
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        var source = tx.getNodeById(targetId);
        cursorTracer.reportEvents();
        assertZeroTracer(cursorContext);
        assertThat(count(source.getRelationships(Direction.INCOMING, relationshipType))).isGreaterThan(0);
        assertThat(cursorTracer.hits()).isEqualTo(3);
        assertThat(cursorTracer.unpins()).isEqualTo(2);
        assertThat(cursorTracer.pins()).isEqualTo(3);
    }
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) Test(org.junit.jupiter.api.Test)

Example 30 with PageCursorTracer

use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.

the class NodeEntityTest method traceNodePageCacheAccessOnDegreeCount.

@Test
void traceNodePageCacheAccessOnDegreeCount() {
    long sourceId;
    try (Transaction tx = db.beginTx()) {
        var source = tx.createNode();
        var relationshipType = RelationshipType.withName("connection");
        createDenseNodeWithShortIncomingChain(tx, source, relationshipType);
        sourceId = source.getId();
        tx.commit();
    }
    try (Transaction tx = db.beginTx()) {
        var cursorContext = ((InternalTransaction) tx).kernelTransaction().cursorContext();
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        var source = tx.getNodeById(sourceId);
        cursorTracer.reportEvents();
        assertZeroTracer(cursorContext);
        source.getDegree(Direction.INCOMING);
        assertThat(cursorTracer.hits()).isEqualTo(3);
        assertThat(cursorTracer.unpins()).isEqualTo(0);
        assertThat(cursorTracer.pins()).isEqualTo(3);
    }
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) Test(org.junit.jupiter.api.Test)

Aggregations

PageCursorTracer (org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer)47 Test (org.junit.jupiter.api.Test)30 CursorContext (org.neo4j.io.pagecache.context.CursorContext)27 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)26 Transaction (org.neo4j.graphdb.Transaction)11 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)5 Path (java.nio.file.Path)2 MutableLong (org.apache.commons.lang3.mutable.MutableLong)2 IndexSample (org.neo4j.kernel.api.index.IndexSample)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 Test (org.junit.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)1 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)1 ExternalStoreId (org.neo4j.storageengine.api.ExternalStoreId)1 IndexEntryUpdate (org.neo4j.storageengine.api.IndexEntryUpdate)1