Search in sources :

Example 21 with DefaultPageCacheTracer

use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer 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 22 with DefaultPageCacheTracer

use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer 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 23 with DefaultPageCacheTracer

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

the class NodeCheckerIT method setUp.

@BeforeEach
void setUp() throws Exception {
    pageCacheTracer = new DefaultPageCacheTracer();
    var label = label("any");
    var propertyName = "property";
    try (var tx = database.beginTx()) {
        var node = tx.createNode(label);
        node.setProperty(propertyName, "nodeValue");
        nodeId = node.getId();
        tx.commit();
    }
    try (var tx = database.beginTx()) {
        tx.schema().indexFor(label).on(propertyName).withName(INDEX_NAME).create();
        tx.commit();
    }
    try (var tx = database.beginTx()) {
        tx.schema().awaitIndexesOnline(10, MINUTES);
    }
    prepareContext();
}
Also used : DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 24 with DefaultPageCacheTracer

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

the class DeleteDuplicateNodesStepTest method tracePageCacheAccessOnNodeDeduplication.

@Test
void tracePageCacheAccessOnNodeDeduplication() throws Exception {
    // given
    Ids[] ids = new Ids[10];
    DataImporter.Monitor monitor = new DataImporter.Monitor();
    for (int i = 0; i < ids.length; i++) {
        ids[i] = createNode(monitor, neoStores, 1, 1);
    }
    long[] duplicateNodeIds = randomNodes(ids);
    SimpleStageControl control = new SimpleStageControl();
    var cacheTracer = new DefaultPageCacheTracer();
    try (DeleteDuplicateNodesStep step = new DeleteDuplicateNodesStep(control, Configuration.DEFAULT, iterator(duplicateNodeIds), neoStores.getNodeStore(), neoStores.getPropertyStore(), monitor, cacheTracer)) {
        control.steps(step);
        startAndAwaitCompletionOf(step);
    }
    control.assertHealthy();
    // at least 2 events per node is expected since property size is dynamic random thingy
    int expectedEventNumber = duplicateNodeIds.length * 2;
    assertThat(cacheTracer.pins()).isGreaterThanOrEqualTo(expectedEventNumber);
    assertThat(cacheTracer.unpins()).isGreaterThanOrEqualTo(expectedEventNumber);
    assertThat(cacheTracer.hits()).isGreaterThanOrEqualTo(expectedEventNumber);
}
Also used : SimpleStageControl(org.neo4j.internal.batchimport.staging.SimpleStageControl) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 25 with DefaultPageCacheTracer

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

the class MuninnPageCacheTest method flushSequentialPagesOnPageFileFlushWithBuffers.

@Test
void flushSequentialPagesOnPageFileFlushWithBuffers() throws IOException {
    assumeFalse(DISABLED_BUFFER_FACTORY.equals(fixture.getBufferFactory()));
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (MuninnPageCache pageCache = createPageCache(fs, 4, pageCacheTracer);
        PagedFile pagedFile = map(pageCache, file("a"), (int) ByteUnit.kibiBytes(8))) {
        try (PageCursor cursor = pagedFile.io(1, PF_SHARED_WRITE_LOCK, NULL)) {
            assertTrue(cursor.next());
            cursor.putLong(1);
        }
        try (PageCursor cursor = pagedFile.io(2, PF_SHARED_WRITE_LOCK, NULL)) {
            assertTrue(cursor.next());
            cursor.putLong(1);
        }
        pagedFile.flushAndForce();
        assertEquals(2, pageCacheTracer.flushes());
        assertEquals(0, pageCacheTracer.merges());
    }
}
Also used : PagedFile(org.neo4j.io.pagecache.PagedFile) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) PageCursor(org.neo4j.io.pagecache.PageCursor) PageCacheTest(org.neo4j.io.pagecache.PageCacheTest) 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