Search in sources :

Example 76 with DefaultPageCacheTracer

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

the class MetaDataStoreTest method tracePageCacheAssessOnGetStoreId.

@Test
void tracePageCacheAssessOnGetStoreId() throws IOException {
    var cacheTracer = new DefaultPageCacheTracer();
    var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAssessOnGetStoreId"));
    try (var metaDataStore = newMetaDataStore()) {
        MetaDataStore.getStoreId(pageCache, metaDataStore.getStorageFile(), databaseLayout.getDatabaseName(), cursorContext);
        PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
        assertThat(cursorTracer.pins()).isEqualTo(5);
        assertThat(cursorTracer.unpins()).isEqualTo(5);
        assertThat(cursorTracer.hits()).isEqualTo(5);
    }
}
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 77 with DefaultPageCacheTracer

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

the class ParallelBatchImporterTest method shouldImportCsvData.

@ParameterizedTest
@MethodSource("params")
void shouldImportCsvData(InputIdGenerator inputIdGenerator, IdType idType) throws Exception {
    this.inputIdGenerator = inputIdGenerator;
    // GIVEN
    ExecutionMonitor processorAssigner = ProcessorAssignmentStrategies.eagerRandomSaturation(config.maxNumberOfProcessors());
    CapturingMonitor monitor = new CapturingMonitor(processorAssigner);
    boolean successful = false;
    Groups groups = new Groups();
    IdGroupDistribution groupDistribution = new IdGroupDistribution(NODE_COUNT, NUMBER_OF_ID_GROUPS, random.random(), groups);
    long nodeRandomSeed = random.nextLong();
    long relationshipRandomSeed = random.nextLong();
    var pageCacheTracer = new DefaultPageCacheTracer();
    JobScheduler jobScheduler = new ThreadPoolJobScheduler();
    // This will have statistically half the nodes be considered dense
    Config dbConfig = Config.defaults(GraphDatabaseSettings.dense_node_threshold, RELATIONSHIPS_PER_NODE * 2);
    IndexImporterFactoryImpl indexImporterFactory = new IndexImporterFactoryImpl(dbConfig);
    final BatchImporter inserter = new ParallelBatchImporter(databaseLayout, fs, pageCacheTracer, config, NullLogService.getInstance(), monitor, EMPTY, dbConfig, getFormat(), ImportLogic.NO_MONITOR, jobScheduler, Collector.EMPTY, TransactionLogInitializer.getLogFilesInitializer(), indexImporterFactory, INSTANCE);
    LongAdder propertyCount = new LongAdder();
    LongAdder relationshipCount = new LongAdder();
    try {
        // WHEN
        inserter.doImport(Input.input(nodes(nodeRandomSeed, NODE_COUNT, config.batchSize(), inputIdGenerator, groupDistribution, propertyCount), relationships(relationshipRandomSeed, RELATIONSHIP_COUNT, config.batchSize(), inputIdGenerator, groupDistribution, propertyCount, relationshipCount), idType, knownEstimates(NODE_COUNT, RELATIONSHIP_COUNT, NODE_COUNT * TOKENS.length / 2, RELATIONSHIP_COUNT * TOKENS.length / 2, NODE_COUNT * TOKENS.length / 2 * Long.BYTES, RELATIONSHIP_COUNT * TOKENS.length / 2 * Long.BYTES, NODE_COUNT * TOKENS.length / 2), groups));
        assertThat(pageCacheTracer.pins()).isGreaterThan(0);
        assertThat(pageCacheTracer.pins()).isEqualTo(pageCacheTracer.unpins());
        assertThat(pageCacheTracer.pins()).isEqualTo(Math.addExact(pageCacheTracer.faults(), pageCacheTracer.hits()));
        // THEN
        DatabaseManagementService managementService = getDBMSBuilder(databaseLayout).build();
        GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
        try (Transaction tx = db.beginTx()) {
            inputIdGenerator.reset();
            verifyData(NODE_COUNT, RELATIONSHIP_COUNT, db, tx, groupDistribution, nodeRandomSeed, relationshipRandomSeed);
            tx.commit();
        } finally {
            managementService.shutdown();
        }
        assertConsistent(databaseLayout);
        successful = true;
    } finally {
        jobScheduler.close();
        if (!successful) {
            Path failureFile = databaseLayout.databaseDirectory().resolve("input");
            try (PrintStream out = new PrintStream(Files.newOutputStream(failureFile))) {
                out.println("Seed used in this failing run: " + random.seed());
                out.println(inputIdGenerator);
                inputIdGenerator.reset();
                out.println();
                out.println("Processor assignments");
                out.println(processorAssigner.toString());
            }
            System.err.println("Additional debug information stored in " + failureFile);
        }
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) Path(java.nio.file.Path) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) PrintStream(java.io.PrintStream) Config(org.neo4j.configuration.Config) LongAdder(java.util.concurrent.atomic.LongAdder) Transaction(org.neo4j.graphdb.Transaction) Groups(org.neo4j.internal.batchimport.input.Groups) IndexImporterFactoryImpl(org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl) ExecutionMonitor(org.neo4j.internal.batchimport.staging.ExecutionMonitor) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 78 with DefaultPageCacheTracer

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

the class IndexPopulatorTests method dropShouldNotFlushContent.

@Test
void dropShouldNotFlushContent() throws IOException {
    // given
    DefaultPageCacheTracer tracer = new DefaultPageCacheTracer();
    try (PageCache pageCache = pageCacheExtension.getPageCache(fs, PageCacheConfig.config().withTracer(tracer))) {
        populator = createPopulator(pageCache);
        populator.create();
        long preDrop = tracer.flushes();
        // when
        populator.drop();
        // then
        long postDrop = tracer.flushes();
        assertEquals(preDrop, postDrop);
    }
}
Also used : PageCache(org.neo4j.io.pagecache.PageCache) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 79 with DefaultPageCacheTracer

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

the class PropertyCreatorTest method startStore.

@BeforeEach
void startStore() {
    neoStores = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName()), pageCache, fileSystem, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable()).openNeoStores(true, StoreType.PROPERTY, StoreType.PROPERTY_STRING, StoreType.PROPERTY_ARRAY);
    propertyStore = neoStores.getPropertyStore();
    records = new DirectRecordAccess<>(propertyStore, Loaders.propertyLoader(propertyStore, NULL));
    var pageCacheTracer = new DefaultPageCacheTracer();
    cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("propertyStore"));
    creator = new PropertyCreator(propertyStore, new PropertyTraverser(NULL), cursorContext, INSTANCE);
}
Also used : DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) CursorContext(org.neo4j.io.pagecache.context.CursorContext) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) 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