use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class CountsComputerTest method tracePageCacheAccessOnInitialization.
@Test
void tracePageCacheAccessOnInitialization() throws IOException {
DatabaseManagementService managementService = dbBuilder.build();
try {
GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
var countsStore = db.getDependencyResolver().resolveDependency(GBPTreeCountsStore.class);
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnInitialization"));
countsStore.start(cursorContext, INSTANCE);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
softly.assertThat(cursorTracer.pins()).as("Pins").isEqualTo(1);
softly.assertThat(cursorTracer.unpins()).as("Unpins").isEqualTo(1);
softly.assertThat(cursorTracer.hits()).as("hits").isEqualTo(1);
} finally {
managementService.shutdown();
}
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class CsvImporterTest method tracePageCacheAccessOnCsvImport.
@Test
void tracePageCacheAccessOnCsvImport() throws IOException {
Path logDir = testDir.directory("logs");
Path reportLocation = testDir.file("the_report");
Path inputFile = testDir.file("foobar.csv");
List<String> lines = List.of("foo;bar;baz");
Files.write(inputFile, lines, Charset.defaultCharset());
Config config = Config.defaults(GraphDatabaseSettings.logs_directory, logDir.toAbsolutePath());
var cacheTracer = new DefaultPageCacheTracer();
CsvImporter csvImporter = CsvImporter.builder().withDatabaseLayout(databaseLayout).withDatabaseConfig(config).withReportFile(reportLocation.toAbsolutePath()).withFileSystem(testDir.getFileSystem()).withPageCacheTracer(cacheTracer).addNodeFiles(emptySet(), new Path[] { inputFile.toAbsolutePath() }).build();
csvImporter.doImport();
long pins = cacheTracer.pins();
assertThat(pins).isGreaterThan(0);
assertThat(cacheTracer.unpins()).isEqualTo(pins);
assertThat(cacheTracer.hits()).isGreaterThan(0).isLessThanOrEqualTo(pins);
assertThat(cacheTracer.faults()).isGreaterThan(0).isLessThanOrEqualTo(pins);
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class EncodeGroupsStepTest method tracePageCacheAccessOnEncode.
@Test
void tracePageCacheAccessOnEncode() throws Exception {
when(store.nextId(any(CursorContext.class))).thenAnswer(invocation -> {
CursorContext cursorContext = invocation.getArgument(0);
var event = cursorContext.getCursorTracer().beginPin(false, 1, null);
event.hit();
event.done();
return 1L;
});
var cacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAccessOnEncode"));
Configuration config = Configuration.withBatchSize(Configuration.DEFAULT, 10);
try (EncodeGroupsStep encoder = new EncodeGroupsStep(control, config, store, PageCacheTracer.NULL)) {
encoder.start(Step.ORDER_SEND_DOWNSTREAM);
Catcher catcher = new Catcher();
encoder.process(batch(new Group(1, 3), new Group(2, 3), new Group(3, 4)), catcher, cursorContext);
encoder.endOfUpstream();
encoder.awaitCompleted();
}
assertThat(cursorContext.getCursorTracer().pins()).isEqualTo(10);
assertThat(cursorContext.getCursorTracer().hits()).isEqualTo(10);
assertThat(cursorContext.getCursorTracer().unpins()).isEqualTo(10);
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class NodeImporterTest method tracePageCacheAccessOnNodeImport.
@Test
void tracePageCacheAccessOnNodeImport() throws IOException {
JobScheduler scheduler = new ThreadPoolJobScheduler();
try (Lifespan life = new Lifespan(scheduler);
BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache(fs, pageCache, NULL, layout, Standard.LATEST_RECORD_FORMATS, Configuration.DEFAULT, NullLogService.getInstance(), AdditionalInitialIds.EMPTY, Config.defaults(), INSTANCE)) {
stores.createNew();
int numberOfLabels = 50;
long nodeId = 0;
var cacheTracer = new DefaultPageCacheTracer();
try (NodeImporter importer = new NodeImporter(stores, IdMappers.actual(), new DataImporter.Monitor(), cacheTracer, INSTANCE)) {
importer.id(nodeId);
String[] labels = new String[numberOfLabels];
for (int i = 0; i < labels.length; i++) {
labels[i] = "Label" + i;
}
importer.labels(labels);
importer.property("a", randomAscii(10));
importer.property("b", randomAscii(100));
importer.property("c", randomAscii(1000));
importer.endOfEntity();
}
NodeStore nodeStore = stores.getNodeStore();
NodeRecord record = nodeStore.getRecord(nodeId, nodeStore.newRecord(), RecordLoad.NORMAL, CursorContext.NULL);
long[] labels = NodeLabelsField.parseLabelsField(record).get(nodeStore, CursorContext.NULL);
assertEquals(numberOfLabels, labels.length);
assertThat(cacheTracer.faults()).isEqualTo(2);
assertThat(cacheTracer.pins()).isEqualTo(13);
assertThat(cacheTracer.unpins()).isEqualTo(13);
assertThat(cacheTracer.hits()).isEqualTo(11);
}
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class MuninnPageCacheStressIT method shouldHandleTheStressOfManyManyEvictions.
@Test
void shouldHandleTheStressOfManyManyEvictions() throws Exception {
DefaultPageCacheTracer monitor = new DefaultPageCacheTracer();
Condition condition = numberOfEvictions(monitor, 100_000);
PageCacheStressTest runner = new PageCacheStressTest.Builder().withWorkingDirectory(testDirectory.homePath()).with(monitor).with(condition).build();
runner.run();
}
Aggregations