Search in sources :

Example 16 with PageCursorTracer

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

the class GBPTreeSingleWriterTest method trackPageCacheAccessOnMerge.

@Test
void trackPageCacheAccessOnMerge() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnMerge"));
    assertZeroCursor(cursorContext);
    try (var gbpTree = new GBPTreeBuilder<>(pageCache, directory.file("index"), layout).build();
        var treeWriter = gbpTree.writer(0, cursorContext)) {
        treeWriter.merge(new MutableLong(0), new MutableLong(1), ValueMergers.overwrite());
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(5);
        assertThat(cursorTracer.unpins()).isEqualTo(4);
        assertThat(cursorTracer.hits()).isEqualTo(4);
        assertThat(cursorTracer.faults()).isEqualTo(1);
    }
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) 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 17 with PageCursorTracer

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

the class GBPTreeSingleWriterTest method trackPageCacheAccessOnPut.

@Test
void trackPageCacheAccessOnPut() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnPut"));
    assertZeroCursor(cursorContext);
    try (var gbpTree = new GBPTreeBuilder<>(pageCache, directory.file("index"), layout).build();
        var treeWriter = gbpTree.writer(0, cursorContext)) {
        treeWriter.put(new MutableLong(0), new MutableLong(1));
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(5);
        assertThat(cursorTracer.unpins()).isEqualTo(4);
        assertThat(cursorTracer.hits()).isEqualTo(4);
        assertThat(cursorTracer.faults()).isEqualTo(1);
    }
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) 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 18 with PageCursorTracer

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

the class MetaDataStoreTest method tracePageCacheAccessOnGetRecord.

@Test
void tracePageCacheAccessOnGetRecord() throws IOException {
    var cacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAccessOnGetRecord"));
    try (var metaDataStore = newMetaDataStore()) {
        MetaDataStore.getRecord(pageCache, metaDataStore.getStorageFile(), MetaDataStore.Position.RANDOM_NUMBER, 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 19 with PageCursorTracer

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

the class MetaDataStoreTest method tracePageCacheAssessOnIncrementAndGetVersion.

@Test
void tracePageCacheAssessOnIncrementAndGetVersion() {
    var cacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAssessOnIncrementAndGetVersion"));
    try (var metaDataStore = newMetaDataStore()) {
        metaDataStore.incrementAndGetVersion(cursorContext);
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(1);
        assertThat(cursorTracer.unpins()).isEqualTo(1);
        assertThat(cursorTracer.hits()).isEqualTo(1);
    }
}
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 20 with PageCursorTracer

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

the class TxStateTransactionDataSnapshotIT method tracePageCacheAccessOnTransactionSnapshotCreation.

@Test
void tracePageCacheAccessOnTransactionSnapshotCreation() {
    long nodeId;
    long relationshipId;
    try (Transaction transaction = database.beginTx()) {
        var node1 = transaction.createNode();
        var node2 = transaction.createNode();
        var relationship = node1.createRelationshipTo(node2, withName("marker"));
        node1.setProperty("foo", "bar");
        nodeId = node1.getId();
        relationshipId = relationship.getId();
        transaction.commit();
    }
    try (Transaction transaction = database.beginTx()) {
        transaction.getNodeById(nodeId).delete();
        transaction.getRelationshipById(relationshipId).delete();
        var kernelTransaction = getKernelTransaction(transaction);
        var transactionState = kernelTransaction.txState();
        var cursorContext = kernelTransaction.cursorContext();
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        cursorTracer.reportEvents();
        try (var snapshot = new TxStateTransactionDataSnapshot(transactionState, kernelTransaction.newStorageReader(), kernelTransaction)) {
        // no work for snapshot
        }
        assertThat(cursorTracer.pins()).isEqualTo(3);
        assertThat(cursorTracer.hits()).isEqualTo(3);
        assertThat(cursorTracer.unpins()).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