use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class IndexingServiceIntegrationTest method tracePageCacheAccessOnIndexUpdatesApply.
@ParameterizedTest
@MethodSource("parameters")
void tracePageCacheAccessOnIndexUpdatesApply(GraphDatabaseSettings.SchemaIndex schemaIndex) throws KernelException {
setUp(schemaIndex);
var marker = Label.label("marker");
var propertyName = "property";
var testConstraint = "testConstraint";
try (Transaction transaction = database.beginTx()) {
transaction.schema().constraintFor(marker).withName(testConstraint).assertPropertyIsUnique(propertyName).create();
transaction.commit();
}
var dependencyResolver = ((GraphDatabaseAPI) database).getDependencyResolver();
var indexingService = dependencyResolver.resolveDependency(IndexingService.class);
var pageCacheTracer = dependencyResolver.resolveDependency(PageCacheTracer.class);
try (Transaction transaction = database.beginTx()) {
var kernelTransaction = ((InternalTransaction) transaction).kernelTransaction();
var indexDescriptor = kernelTransaction.schemaRead().indexGetForName(testConstraint);
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnIndexUpdatesApply"))) {
Iterable<IndexEntryUpdate<IndexDescriptor>> updates = List.of(add(1, indexDescriptor, longValue(4)));
indexingService.applyUpdates(updates, cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertEquals(5L, cursorTracer.pins());
assertEquals(5L, cursorTracer.unpins());
assertEquals(2L, cursorTracer.hits());
assertEquals(3L, cursorTracer.faults());
}
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class NeoStoresTest method tracePageCacheAccessOnTransactionCloseCall.
@Test
void tracePageCacheAccessOnTransactionCloseCall() {
StoreFactory factory = getStoreFactory(Config.defaults(), databaseLayout, fs, LOG_PROVIDER);
try (NeoStores neoStore = factory.openAllNeoStores(true)) {
MetaDataStore store = neoStore.getMetaDataStore();
var cacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAccessOnTransactionCloseCall"));
store.transactionClosed(store.nextCommittingTransactionId(), 6666, 15, cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertEquals(1, cursorTracer.pins());
assertEquals(1, cursorTracer.hits());
assertEquals(1, cursorTracer.unpins());
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class NeoStoresIT method tracePageCacheAccessOnUpdateRecord.
@Test
void tracePageCacheAccessOnUpdateRecord() {
var storageEngine = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class);
var neoStores = storageEngine.testAccessNeoStores();
var nodeStore = neoStores.getNodeStore();
long nodeId;
try (Transaction transaction = db.beginTx()) {
var node = transaction.createNode();
node.setProperty("a", "b");
nodeId = node.getId();
transaction.commit();
}
var cursorContext = new CursorContext(new DefaultPageCacheTracer().createPageCursorTracer("tracePageCacheAccessOnUpdateRecord"));
nodeStore.updateRecord(new NodeRecord(nodeId), cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertEquals(5, cursorTracer.hits());
assertEquals(6, cursorTracer.pins());
assertEquals(6, cursorTracer.unpins());
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class NeoStoresIT method tracePageCacheAccessOnHighIdScan.
@Test
void tracePageCacheAccessOnHighIdScan() {
var storageEngine = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class);
var neoStores = storageEngine.testAccessNeoStores();
var propertyStore = neoStores.getPropertyStore();
for (int i = 0; i < 1000; i++) {
try (Transaction transaction = db.beginTx()) {
var node = transaction.createNode();
node.setProperty("a", randomAscii(1024));
transaction.commit();
}
}
var cursorContext = new CursorContext(new DefaultPageCacheTracer().createPageCursorTracer("tracePageCacheAccessOnHighIdScan"));
propertyStore.scanForHighId(cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertEquals(1, cursorTracer.hits());
assertEquals(1, cursorTracer.pins());
assertEquals(1, cursorTracer.unpins());
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class NeoStoresIT method tracePageCacheAccessOnGetRawRecordData.
@Test
void tracePageCacheAccessOnGetRawRecordData() throws IOException {
var storageEngine = db.getDependencyResolver().resolveDependency(RecordStorageEngine.class);
var neoStores = storageEngine.testAccessNeoStores();
var propertyStore = neoStores.getPropertyStore();
try (Transaction transaction = db.beginTx()) {
var node = transaction.createNode();
node.setProperty("a", "b");
transaction.commit();
}
var cursorContext = new CursorContext(new DefaultPageCacheTracer().createPageCursorTracer("tracePageCacheAccessOnGetRawRecordData"));
propertyStore.getRawRecordData(1L, cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertEquals(1, cursorTracer.hits());
assertEquals(1, cursorTracer.pins());
assertEquals(1, cursorTracer.unpins());
}
Aggregations