Search in sources :

Example 51 with DefaultPageCacheTracer

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

the class IdContextFactoryBuilderTest method useProvidedPageCacheCursorOnIdMaintenance.

@Test
void useProvidedPageCacheCursorOnIdMaintenance() throws IOException {
    PageCacheTracer cacheTracer = new DefaultPageCacheTracer();
    Config config = defaults();
    var idContextFactory = IdContextFactoryBuilder.of(fs, jobScheduler, config, cacheTracer).build();
    var idContext = idContextFactory.createIdContext(from("test", UUID.randomUUID()));
    var idGeneratorFactory = idContext.getIdGeneratorFactory();
    var idController = idContext.getIdController();
    idController.initialize(() -> () -> true);
    Path file = testDirectory.file("b");
    IdType idType = IdType.NODE;
    try (IdGenerator idGenerator = idGeneratorFactory.create(pageCache, file, idType, 1, false, 100, writable(), config, NULL, immutable.empty())) {
        idGenerator.marker(NULL).markDeleted(1);
        idGeneratorFactory.clearCache(NULL);
        assertThat(cacheTracer.pins()).isZero();
        assertThat(cacheTracer.unpins()).isZero();
        assertThat(cacheTracer.hits()).isZero();
        idController.maintenance();
        assertThat(cacheTracer.pins()).isGreaterThan(0);
        assertThat(cacheTracer.unpins()).isGreaterThan(0);
        assertThat(cacheTracer.hits()).isGreaterThan(0);
    }
}
Also used : Path(java.nio.file.Path) Config(org.neo4j.configuration.Config) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) IdGenerator(org.neo4j.internal.id.IdGenerator) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) IdType(org.neo4j.internal.id.IdType) Test(org.junit.jupiter.api.Test)

Example 52 with DefaultPageCacheTracer

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

the class SimpleIndexAccessorCompatibility method tracePageCacheAccessOnConsistencyCheck.

@Test
public void tracePageCacheAccessOnConsistencyCheck() {
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnConsistencyCheck"))) {
        accessor.consistencyCheck(ReporterFactories.noopReporterFactory(), cursorContext);
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(2);
        assertThat(cursorTracer.unpins()).isEqualTo(2);
        assertThat(cursorTracer.faults()).isEqualTo(2);
    }
}
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.Test)

Example 53 with DefaultPageCacheTracer

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

the class PropertyStoreTraceIT method tracePageCacheAccessOnPropertyBlockIdGeneration.

@Test
void tracePageCacheAccessOnPropertyBlockIdGeneration() {
    var propertyStore = storageEngine.testAccessNeoStores().getPropertyStore();
    prepareIdGenerator(propertyStore.getStringStore().getIdGenerator());
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnPropertyBlockIdGeneration"))) {
        var propertyBlock = new PropertyBlock();
        var dynamicRecord = new DynamicRecord(2);
        dynamicRecord.setData(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 });
        propertyBlock.addValueRecord(dynamicRecord);
        propertyStore.encodeValue(propertyBlock, 1, stringValue(randomAlphabetic((int) kibiBytes(4))), cursorContext, INSTANCE);
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isOne();
        assertThat(cursorTracer.unpins()).isOne();
        assertThat(cursorTracer.hits()).isOne();
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 54 with DefaultPageCacheTracer

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

the class CommitProcessTracingIT method tracePageCacheAccessOnTransactionApply.

@Test
void tracePageCacheAccessOnTransactionApply() throws TransactionFailureException {
    var transaction = new PhysicalTransactionRepresentation(List.of(new Command.NodeCountsCommand(1, 2)), EMPTY_BYTE_ARRAY, 0, 0, 0, 0, ANONYMOUS);
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnTransactionApply"))) {
        assertZeroCursor(cursorContext);
        commitProcess.commit(new TransactionToApply(transaction, cursorContext), NULL, EXTERNAL);
        assertCursor(cursorContext, 3);
    }
}
Also used : TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) CursorContext(org.neo4j.io.pagecache.context.CursorContext) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 55 with DefaultPageCacheTracer

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

the class IndexIteratorIT method setUp.

@BeforeEach
void setUp() throws IOException {
    var label = label("any");
    var propertyName = "property";
    try (var tx = database.beginTx()) {
        var node = tx.createNode(label);
        node.setProperty(propertyName, "nodeValue");
        tx.commit();
    }
    try (var tx = database.beginTx()) {
        tx.schema().indexFor(label).on(propertyName).withName(INDEX_NAME).create();
        tx.commit();
    }
    try (var transaction = database.beginTx()) {
        transaction.schema().awaitIndexesOnline(10, MINUTES);
    }
    var neoStores = storageEngine.testAccessNeoStores();
    indexAccessors = new IndexAccessors(providerMap, neoStores, new IndexSamplingConfig(config), PageCacheTracer.NULL, SIMPLE_NAME_LOOKUP, () -> KernelVersion.LATEST);
    pageCacheTracer = new DefaultPageCacheTracer();
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.IndexSamplingConfig) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) BeforeEach(org.junit.jupiter.api.BeforeEach)

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