Search in sources :

Example 16 with DefaultPageCacheTracer

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

the class CommitProcessTracingIT method tracePageCacheAccessOnCommandCreation.

@Test
void tracePageCacheAccessOnCommandCreation() throws KernelException {
    long sourceId;
    try (Transaction transaction = database.beginTx()) {
        sourceId = transaction.createNode(Label.label("a")).getId();
        transaction.commit();
    }
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnCommandCreation"));
        var reader = storageEngine.newReader()) {
        assertZeroCursor(cursorContext);
        try (CommandCreationContext context = storageEngine.newCommandCreationContext(INSTANCE)) {
            context.initialize(cursorContext);
            List<StorageCommand> commands = new ArrayList<>();
            var txState = new TxState();
            txState.nodeDoAddLabel(1, sourceId);
            storageEngine.createCommands(commands, txState, reader, context, IGNORE, LockTracer.NONE, 0, NO_DECORATION, cursorContext, INSTANCE);
        }
        assertCursor(cursorContext, 2);
    }
}
Also used : CommandCreationContext(org.neo4j.storageengine.api.CommandCreationContext) Transaction(org.neo4j.graphdb.Transaction) TxState(org.neo4j.kernel.impl.api.state.TxState) StorageCommand(org.neo4j.storageengine.api.StorageCommand) ArrayList(java.util.ArrayList) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 17 with DefaultPageCacheTracer

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

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

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

the class GBPTreeTest method trackPageCacheAccessOnTreeSeek.

@Test
void trackPageCacheAccessOnTreeSeek() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (PageCache pageCache = createPageCache((int) ByteUnit.kibiBytes(4));
        var tree = index(pageCache).with(pageCacheTracer).build()) {
        for (int i = 0; i < 1000; i++) {
            insert(tree, i, 1);
        }
        var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnTreeSeek"));
        try (var seeker = tree.seek(new MutableLong(0), new MutableLong(Integer.MAX_VALUE), cursorContext)) {
            while (seeker.next()) {
            // just scroll over the results
            }
        }
        var cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.hits()).isEqualTo(8);
        assertThat(cursorTracer.unpins()).isEqualTo(8);
        assertThat(cursorTracer.pins()).isEqualTo(8);
        assertThat(cursorTracer.faults()).isEqualTo(0);
    }
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) 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 20 with DefaultPageCacheTracer

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

the class GBPTreeTest method shouldNotFlushPagedFileIfDeleteOnClose.

@Test
void shouldNotFlushPagedFileIfDeleteOnClose() throws IOException {
    // GIVEN
    var tracer = new DefaultPageCacheTracer();
    try (PageCache pageCache = pageCacheExtension.getPageCache(fileSystem, config().withTracer(tracer))) {
        // WHEN
        // Closing tree we should see flush happen
        long flushesBeforeClose;
        try (GBPTree<MutableLong, MutableLong> index = index(pageCache).build()) {
            index.setDeleteOnClose(false);
            flushesBeforeClose = tracer.flushes();
        }
        // THEN
        assertThat(tracer.flushes()).isGreaterThan(flushesBeforeClose);
        // Closing with set delete on close we should see no flush
        try (GBPTree<MutableLong, MutableLong> index = index(pageCache).build()) {
            index.setDeleteOnClose(true);
            flushesBeforeClose = tracer.flushes();
        }
        // THEN
        assertThat(tracer.flushes()).isEqualTo(flushesBeforeClose);
    }
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) 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)

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