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());
}
}
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);
}
}
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();
}
}
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);
}
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);
}
}
Aggregations