Search in sources :

Example 26 with DefaultPageCacheTracer

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

the class MuninnPageCacheTest method flushSequentialPagesOnPageFileFlushWithNoBuffers.

@Test
void flushSequentialPagesOnPageFileFlushWithNoBuffers() throws IOException {
    assumeTrue(DISABLED_BUFFER_FACTORY.equals(fixture.getBufferFactory()));
    var pageCacheTracer = new DefaultPageCacheTracer();
    try (MuninnPageCache pageCache = createPageCache(fs, 4, pageCacheTracer);
        PagedFile pagedFile = map(pageCache, file("a"), (int) ByteUnit.kibiBytes(8))) {
        try (PageCursor cursor = pagedFile.io(1, PF_SHARED_WRITE_LOCK, NULL)) {
            assertTrue(cursor.next());
            cursor.putLong(1);
        }
        try (PageCursor cursor = pagedFile.io(2, PF_SHARED_WRITE_LOCK, NULL)) {
            assertTrue(cursor.next());
            cursor.putLong(1);
        }
        pagedFile.flushAndForce();
        assertEquals(2, pageCacheTracer.flushes());
        assertEquals(1, pageCacheTracer.merges());
    }
}
Also used : PagedFile(org.neo4j.io.pagecache.PagedFile) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) PageCursor(org.neo4j.io.pagecache.PageCursor) PageCacheTest(org.neo4j.io.pagecache.PageCacheTest) Test(org.junit.jupiter.api.Test)

Example 27 with DefaultPageCacheTracer

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

the class MuninnPageCacheTest method shouldBeAbleToSetDeleteOnCloseFileAfterItWasMapped.

@Test
void shouldBeAbleToSetDeleteOnCloseFileAfterItWasMapped() throws IOException {
    DefaultPageCacheTracer defaultPageCacheTracer = new DefaultPageCacheTracer();
    Path fileForDeletion = file("fileForDeletion");
    writeInitialDataTo(fileForDeletion);
    long initialFlushes = defaultPageCacheTracer.flushes();
    try (MuninnPageCache pageCache = createPageCache(fs, 2, defaultPageCacheTracer)) {
        try (var cursorContext = new CursorContext(defaultPageCacheTracer.createPageCursorTracer("shouldBeAbleToSetDeleteOnCloseFileAfterItWasMapped"));
            PagedFile pagedFile = map(pageCache, fileForDeletion, 8)) {
            try (PageCursor cursor = pagedFile.io(0, PF_SHARED_WRITE_LOCK, cursorContext)) {
                assertTrue(cursor.next());
                cursor.putLong(0L);
            }
            pagedFile.setDeleteOnClose(true);
        }
        assertFalse(fs.fileExists(fileForDeletion));
        assertEquals(0, defaultPageCacheTracer.flushes() - initialFlushes);
    }
}
Also used : Path(java.nio.file.Path) PagedFile(org.neo4j.io.pagecache.PagedFile) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) PageCursor(org.neo4j.io.pagecache.PageCursor) PageCacheTest(org.neo4j.io.pagecache.PageCacheTest) Test(org.junit.jupiter.api.Test)

Example 28 with DefaultPageCacheTracer

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

the class RecoveryIT method tracePageCacheAccessOnDatabaseRecovery.

@Test
void tracePageCacheAccessOnDatabaseRecovery() throws Throwable {
    GraphDatabaseService database = createDatabase();
    int numberOfNodes = 10;
    for (int i = 0; i < numberOfNodes; i++) {
        createSingleNode(database);
    }
    managementService.shutdown();
    RecoveryHelpers.removeLastCheckpointRecordFromLastLogFile(databaseLayout, fileSystem);
    var pageCacheTracer = new DefaultPageCacheTracer();
    var tracers = new DatabaseTracers(DatabaseTracer.NULL, LockTracer.NONE, pageCacheTracer);
    recoverDatabase(tracers);
    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);
    GraphDatabaseService recoveredDatabase = createDatabase();
    try (Transaction tx = recoveredDatabase.beginTx()) {
        assertEquals(numberOfNodes, count(tx.getAllNodes()));
    } finally {
        managementService.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) DatabaseTracers(org.neo4j.kernel.database.DatabaseTracers) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 29 with DefaultPageCacheTracer

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

the class FullScanStoreViewTest method tracePageCacheAccessOnStoreViewNodeScan.

@Test
void tracePageCacheAccessOnStoreViewNodeScan() throws IOException {
    // enforce checkpoint to flush tree caches
    checkPointer.forceCheckPoint(new SimpleTriggerInfo("forcedCheckpoint"));
    var pageCacheTracer = new DefaultPageCacheTracer();
    var propertyScanConsumer = new TestPropertyScanConsumer();
    var scan = new NodeStoreScan(Config.defaults(), storageEngine.newReader(), locks, null, propertyScanConsumer, new int[] { labelId }, id -> true, false, jobScheduler, pageCacheTracer, INSTANCE);
    scan.run(NO_EXTERNAL_UPDATES);
    assertThat(propertyScanConsumer.batches.get(0).size()).isEqualTo(2);
    assertThat(pageCacheTracer.pins()).isEqualTo(4);
    assertThat(pageCacheTracer.unpins()).isEqualTo(4);
    assertThat(pageCacheTracer.hits()).isEqualTo(4);
}
Also used : SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 30 with DefaultPageCacheTracer

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

the class ConsistencyCheckServiceIntegrationTest method tracePageCacheAccessOnConsistencyCheck.

@Test
void tracePageCacheAccessOnConsistencyCheck() throws ConsistencyCheckIncompleteException {
    prepareDbWithDeletedRelationshipPartOfTheChain();
    ConsistencyCheckService service = new ConsistencyCheckService(new Date());
    var pageCacheTracer = new DefaultPageCacheTracer();
    fixture.close();
    JobScheduler jobScheduler = JobSchedulerFactory.createScheduler();
    ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(testDirectory.getFileSystem(), Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m"), pageCacheTracer, NullLog.getInstance(), jobScheduler, Clocks.nanoClock(), new MemoryPools(false));
    try (Lifespan life = new Lifespan(jobScheduler);
        PageCache pageCache = pageCacheFactory.getOrCreatePageCache()) {
        var result = service.runFullConsistencyCheck(fixture.databaseLayout(), Config.defaults(settings()), ProgressMonitorFactory.NONE, NullLogProvider.getInstance(), testDirectory.getFileSystem(), pageCache, false, ConsistencyFlags.DEFAULT, pageCacheTracer, INSTANCE);
        assertFalse(result.isSuccessful());
        assertThat(pageCacheTracer.pins()).isGreaterThanOrEqualTo(74);
        assertThat(pageCacheTracer.unpins()).isGreaterThanOrEqualTo(74);
        assertThat(pageCacheTracer.hits()).isGreaterThanOrEqualTo(35);
        assertThat(pageCacheTracer.faults()).isGreaterThanOrEqualTo(39);
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) MemoryPools(org.neo4j.memory.MemoryPools) ConfiguringPageCacheFactory(org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) Date(java.util.Date) PageCache(org.neo4j.io.pagecache.PageCache) 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