Search in sources :

Example 61 with DefaultPageCacheTracer

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

the class GBPTreeSingleWriterTest method trackPageCacheAccessOnClose.

@Test
void trackPageCacheAccessOnClose() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnClose"));
    assertZeroCursor(cursorContext);
    try (var gbpTree = new GBPTreeBuilder<>(pageCache, directory.file("index"), layout).build();
        var treeWriter = gbpTree.writer(0, cursorContext)) {
    // empty, we check that closing everything register unpins event
    }
    PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
    assertThat(cursorTracer.pins()).isEqualTo(1);
    assertThat(cursorTracer.hits()).isEqualTo(1);
    assertThat(cursorTracer.unpins()).isEqualTo(1);
    assertThat(cursorTracer.faults()).isEqualTo(0);
}
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 62 with DefaultPageCacheTracer

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

the class GBPTreeSingleWriterTest method trackPageCacheAccessOnRemove.

@Test
void trackPageCacheAccessOnRemove() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnRemove"));
    try (var gbpTree = new GBPTreeBuilder<>(pageCache, directory.file("index"), layout).build();
        var treeWriter = gbpTree.writer(0, cursorContext)) {
        treeWriter.put(new MutableLong(0), new MutableLong(0));
        var cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(5);
        assertThat(cursorTracer.unpins()).isEqualTo(4);
        assertThat(cursorTracer.hits()).isEqualTo(4);
        assertThat(cursorTracer.faults()).isEqualTo(1);
        cursorTracer.reportEvents();
        assertZeroCursor(cursorContext);
        // we are on the same page and we do not expect any cursor events to be registered
        treeWriter.remove(new MutableLong(0));
        assertZeroCursor(cursorContext);
    }
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 63 with DefaultPageCacheTracer

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

the class GBPTreeTest method trackPageCacheAccessOnVisit.

@Test
void trackPageCacheAccessOnVisit() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (PageCache pageCache = createPageCache(defaultPageSize);
        var tree = index(pageCache).with(pageCacheTracer).build()) {
        var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("traverseTree"));
        tree.visit(new GBPTreeVisitor.Adaptor<>(), cursorContext);
        var cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(5);
        assertThat(cursorTracer.unpins()).isEqualTo(5);
        assertThat(cursorTracer.hits()).isEqualTo(5);
    }
}
Also used : CursorContext(org.neo4j.io.pagecache.context.CursorContext) PageCache(org.neo4j.io.pagecache.PageCache) DelegatingPageCache(org.neo4j.io.pagecache.DelegatingPageCache) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 64 with DefaultPageCacheTracer

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

the class RecordStoreVersionCheckTest method tracePageCacheAccessOnStoreVersionAccessConstruction.

@Test
void tracePageCacheAccessOnStoreVersionAccessConstruction() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnStoreVersionAccessConstruction"));
    Path neoStore = emptyFile(fileSystem);
    String storeVersion = "V1";
    long v1 = MetaDataStore.versionStringToLong(storeVersion);
    MetaDataStore.setRecord(pageCache, neoStore, MetaDataStore.Position.STORE_VERSION, v1, databaseLayout.getDatabaseName(), NULL);
    var versionCheck = newStoreVersionCheck();
    assertEquals(storeVersion, versionCheck.storeVersion(cursorContext).get());
    PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
    assertThat(cursorTracer.pins()).isOne();
    assertThat(cursorTracer.unpins()).isOne();
    assertThat(cursorTracer.faults()).isOne();
}
Also used : Path(java.nio.file.Path) 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 65 with DefaultPageCacheTracer

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

the class RecordStoreVersionCheckTest method tracePageCacheAccessOnCheckUpgradable.

@Test
void tracePageCacheAccessOnCheckUpgradable() throws IOException {
    Path neoStore = emptyFile(fileSystem);
    String storeVersion = "V1";
    long v1 = MetaDataStore.versionStringToLong(storeVersion);
    MetaDataStore.setRecord(pageCache, neoStore, MetaDataStore.Position.STORE_VERSION, v1, databaseLayout.getDatabaseName(), NULL);
    RecordStoreVersionCheck storeVersionCheck = newStoreVersionCheck();
    var pageCacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnCheckUpgradable"));
    StoreVersionCheck.Result result = storeVersionCheck.checkUpgrade(storeVersion, cursorContext);
    assertTrue(result.outcome.isSuccessful());
    PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
    assertThat(cursorTracer.pins()).isOne();
    assertThat(cursorTracer.unpins()).isOne();
    assertThat(cursorTracer.faults()).isOne();
}
Also used : Path(java.nio.file.Path) StoreVersionCheck(org.neo4j.storageengine.api.StoreVersionCheck) 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)

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