Search in sources :

Example 56 with DefaultPageCacheTracer

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

the class IndexPopulationJobTest method tracePageCacheAccessIndexWithOneNodePopulation.

@Test
void tracePageCacheAccessIndexWithOneNodePopulation() throws KernelException {
    var value = "value";
    long nodeId = createNode(map(name, value), FIRST);
    IndexPopulator actualPopulator = indexPopulator(false);
    TrackingIndexPopulator populator = new TrackingIndexPopulator(actualPopulator);
    int label = tokenHolders.labelTokens().getIdByName(FIRST.name());
    int prop = tokenHolders.propertyKeyTokens().getIdByName(name);
    LabelSchemaDescriptor descriptor = SchemaDescriptor.forLabel(label, prop);
    var pageCacheTracer = new DefaultPageCacheTracer();
    IndexPopulationJob job = newIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.NODE, IndexPrototype.forSchema(descriptor), pageCacheTracer);
    job.run();
    IndexEntryUpdate<?> update = IndexEntryUpdate.add(nodeId, descriptor, Values.of(value));
    assertTrue(populator.created);
    assertEquals(Collections.singletonList(update), populator.includedSamples);
    assertEquals(1, populator.adds.size());
    assertTrue(populator.resultSampled);
    assertTrue(populator.closeCall);
    long pins = pageCacheTracer.pins();
    assertThat(pins).isGreaterThan(0);
    assertThat(pageCacheTracer.unpins()).isEqualTo(pins);
    assertThat(pageCacheTracer.hits()).isGreaterThan(0).isLessThanOrEqualTo(pins);
    assertThat(pageCacheTracer.faults()).isGreaterThan(0).isLessThanOrEqualTo(pins);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 57 with DefaultPageCacheTracer

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

the class IndexPopulationJobTest method tracePageCacheAccessIndexWithOneRelationship.

@Test
void tracePageCacheAccessIndexWithOneRelationship() {
    String value = "value";
    long nodeId = createNode(map(name, value), FIRST);
    long relationship = createRelationship(map(name, age), likes, nodeId, nodeId);
    int rel = tokenHolders.relationshipTypeTokens().getIdByName(likes.name());
    int prop = tokenHolders.propertyKeyTokens().getIdByName(name);
    IndexPrototype descriptor = IndexPrototype.forSchema(SchemaDescriptor.forRelType(rel, prop));
    IndexPopulator actualPopulator = indexPopulator(descriptor);
    TrackingIndexPopulator populator = new TrackingIndexPopulator(actualPopulator);
    var pageCacheTracer = new DefaultPageCacheTracer();
    IndexPopulationJob job = newIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.RELATIONSHIP, descriptor, pageCacheTracer);
    job.run();
    IndexEntryUpdate<?> update = IndexEntryUpdate.add(relationship, descriptor, Values.of(age));
    assertTrue(populator.created);
    assertEquals(Collections.singletonList(update), populator.includedSamples);
    assertEquals(1, populator.adds.size());
    assertTrue(populator.resultSampled);
    assertTrue(populator.closeCall);
    assertThat(pageCacheTracer.pins()).isEqualTo(17);
    assertThat(pageCacheTracer.unpins()).isEqualTo(17);
    assertThat(pageCacheTracer.hits()).isEqualTo(16);
    assertThat(pageCacheTracer.faults()).isEqualTo(1);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 58 with DefaultPageCacheTracer

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

the class GBPTreeTest method trackPageCacheAccessOnEmptyTreeSeek.

@Test
void trackPageCacheAccessOnEmptyTreeSeek() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (PageCache pageCache = createPageCache(defaultPageSize);
        var tree = index(pageCache).with(pageCacheTracer).build()) {
        var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnTreeSeek"));
        try (var seeker = tree.seek(new MutableLong(0), new MutableLong(1000), cursorContext)) {
            while (seeker.next()) {
            // just scroll over the results
            }
        }
        var cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.hits()).isEqualTo(1);
        assertThat(cursorTracer.unpins()).isEqualTo(1);
        assertThat(cursorTracer.pins()).isEqualTo(1);
        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 59 with DefaultPageCacheTracer

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

the class GBPTreeTest method skipFlushingPageFileOnCloseWhenPageFileMarkForDeletion.

@Test
void skipFlushingPageFileOnCloseWhenPageFileMarkForDeletion() throws IOException {
    var tracer = new DefaultPageCacheTracer();
    PageCacheConfig config = config().withTracer(tracer);
    long initialPins = tracer.pins();
    try (PageCache pageCache = pageCacheExtension.getPageCache(fileSystem, config);
        GBPTree<MutableLong, MutableLong> tree = index(pageCache).with(RecoveryCleanupWorkCollector.ignore()).with(tracer).build()) {
        List<PagedFile> pagedFiles = pageCache.listExistingMappings();
        assertThat(pagedFiles).hasSize(1);
        long flushesBefore = tracer.flushes();
        PagedFile indexPageFile = pagedFiles.get(0);
        indexPageFile.setDeleteOnClose(true);
        tree.close();
        assertEquals(flushesBefore, tracer.flushes());
        assertEquals(tracer.pins(), tracer.unpins());
        assertThat(tracer.pins()).isGreaterThan(initialPins);
        assertThat(tracer.pins()).isGreaterThan(1);
    }
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) PagedFile(org.neo4j.io.pagecache.PagedFile) DelegatingPagedFile(org.neo4j.io.pagecache.DelegatingPagedFile) PageCacheConfig(org.neo4j.test.rule.PageCacheConfig) 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 60 with DefaultPageCacheTracer

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

the class GBPTreeSingleWriterTest method trackPageCacheAccessOnRemoveWhenNothingToRemove.

@Test
void trackPageCacheAccessOnRemoveWhenNothingToRemove() throws IOException {
    var pageCacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnRemoveWhenNothingToRemove"));
    assertZeroCursor(cursorContext);
    try (var gbpTree = new GBPTreeBuilder<>(pageCache, directory.file("index"), layout).build();
        var treeWriter = gbpTree.writer(0, cursorContext)) {
        treeWriter.remove(new MutableLong(0));
        var cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(1);
        assertThat(cursorTracer.hits()).isEqualTo(1);
        assertThat(cursorTracer.unpins()).isEqualTo(0);
        assertThat(cursorTracer.faults()).isEqualTo(0);
    }
}
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)

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