use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class IndexPopulationJobTest method tracePageCacheAccessIndexWithOneNodePopulation.
@Test
void tracePageCacheAccessIndexWithOneNodePopulation() throws KernelException {
var value = "value";
long nodeId = createNode(map(name, value), FIRST);
IndexPopulator actualPopulator = indexPopulator(false);
TrackingIndexPopulator populator = new TrackingIndexPopulator(actualPopulator);
int label = tokenHolders.labelTokens().getIdByName(FIRST.name());
int prop = tokenHolders.propertyKeyTokens().getIdByName(name);
LabelSchemaDescriptor descriptor = SchemaDescriptor.forLabel(label, prop);
var pageCacheTracer = new DefaultPageCacheTracer();
IndexPopulationJob job = newIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.NODE, IndexPrototype.forSchema(descriptor), pageCacheTracer);
job.run();
IndexEntryUpdate<?> update = IndexEntryUpdate.add(nodeId, descriptor, Values.of(value));
assertTrue(populator.created);
assertEquals(Collections.singletonList(update), populator.includedSamples);
assertEquals(1, populator.adds.size());
assertTrue(populator.resultSampled);
assertTrue(populator.closeCall);
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);
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class IndexPopulationJobTest method tracePageCacheAccessIndexWithOneRelationship.
@Test
void tracePageCacheAccessIndexWithOneRelationship() {
String value = "value";
long nodeId = createNode(map(name, value), FIRST);
long relationship = createRelationship(map(name, age), likes, nodeId, nodeId);
int rel = tokenHolders.relationshipTypeTokens().getIdByName(likes.name());
int prop = tokenHolders.propertyKeyTokens().getIdByName(name);
IndexPrototype descriptor = IndexPrototype.forSchema(SchemaDescriptor.forRelType(rel, prop));
IndexPopulator actualPopulator = indexPopulator(descriptor);
TrackingIndexPopulator populator = new TrackingIndexPopulator(actualPopulator);
var pageCacheTracer = new DefaultPageCacheTracer();
IndexPopulationJob job = newIndexPopulationJob(populator, new FlippableIndexProxy(), EntityType.RELATIONSHIP, descriptor, pageCacheTracer);
job.run();
IndexEntryUpdate<?> update = IndexEntryUpdate.add(relationship, descriptor, Values.of(age));
assertTrue(populator.created);
assertEquals(Collections.singletonList(update), populator.includedSamples);
assertEquals(1, populator.adds.size());
assertTrue(populator.resultSampled);
assertTrue(populator.closeCall);
assertThat(pageCacheTracer.pins()).isEqualTo(17);
assertThat(pageCacheTracer.unpins()).isEqualTo(17);
assertThat(pageCacheTracer.hits()).isEqualTo(16);
assertThat(pageCacheTracer.faults()).isEqualTo(1);
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class GBPTreeTest method trackPageCacheAccessOnEmptyTreeSeek.
@Test
void trackPageCacheAccessOnEmptyTreeSeek() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
try (PageCache pageCache = createPageCache(defaultPageSize);
var tree = index(pageCache).with(pageCacheTracer).build()) {
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnTreeSeek"));
try (var seeker = tree.seek(new MutableLong(0), new MutableLong(1000), cursorContext)) {
while (seeker.next()) {
// just scroll over the results
}
}
var cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.hits()).isEqualTo(1);
assertThat(cursorTracer.unpins()).isEqualTo(1);
assertThat(cursorTracer.pins()).isEqualTo(1);
assertThat(cursorTracer.faults()).isEqualTo(0);
}
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class GBPTreeTest method skipFlushingPageFileOnCloseWhenPageFileMarkForDeletion.
@Test
void skipFlushingPageFileOnCloseWhenPageFileMarkForDeletion() throws IOException {
var tracer = new DefaultPageCacheTracer();
PageCacheConfig config = config().withTracer(tracer);
long initialPins = tracer.pins();
try (PageCache pageCache = pageCacheExtension.getPageCache(fileSystem, config);
GBPTree<MutableLong, MutableLong> tree = index(pageCache).with(RecoveryCleanupWorkCollector.ignore()).with(tracer).build()) {
List<PagedFile> pagedFiles = pageCache.listExistingMappings();
assertThat(pagedFiles).hasSize(1);
long flushesBefore = tracer.flushes();
PagedFile indexPageFile = pagedFiles.get(0);
indexPageFile.setDeleteOnClose(true);
tree.close();
assertEquals(flushesBefore, tracer.flushes());
assertEquals(tracer.pins(), tracer.unpins());
assertThat(tracer.pins()).isGreaterThan(initialPins);
assertThat(tracer.pins()).isGreaterThan(1);
}
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class GBPTreeSingleWriterTest method trackPageCacheAccessOnRemoveWhenNothingToRemove.
@Test
void trackPageCacheAccessOnRemoveWhenNothingToRemove() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnRemoveWhenNothingToRemove"));
assertZeroCursor(cursorContext);
try (var gbpTree = new GBPTreeBuilder<>(pageCache, directory.file("index"), layout).build();
var treeWriter = gbpTree.writer(0, cursorContext)) {
treeWriter.remove(new MutableLong(0));
var cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(1);
assertThat(cursorTracer.hits()).isEqualTo(1);
assertThat(cursorTracer.unpins()).isEqualTo(0);
assertThat(cursorTracer.faults()).isEqualTo(0);
}
}
Aggregations