use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.
the class GBPTreeSingleWriterTest method trackPageCacheAccessOnMerge.
@Test
void trackPageCacheAccessOnMerge() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnMerge"));
assertZeroCursor(cursorContext);
try (var gbpTree = new GBPTreeBuilder<>(pageCache, directory.file("index"), layout).build();
var treeWriter = gbpTree.writer(0, cursorContext)) {
treeWriter.merge(new MutableLong(0), new MutableLong(1), ValueMergers.overwrite());
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(5);
assertThat(cursorTracer.unpins()).isEqualTo(4);
assertThat(cursorTracer.hits()).isEqualTo(4);
assertThat(cursorTracer.faults()).isEqualTo(1);
}
}
use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.
the class GBPTreeSingleWriterTest method trackPageCacheAccessOnPut.
@Test
void trackPageCacheAccessOnPut() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnPut"));
assertZeroCursor(cursorContext);
try (var gbpTree = new GBPTreeBuilder<>(pageCache, directory.file("index"), layout).build();
var treeWriter = gbpTree.writer(0, cursorContext)) {
treeWriter.put(new MutableLong(0), new MutableLong(1));
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(5);
assertThat(cursorTracer.unpins()).isEqualTo(4);
assertThat(cursorTracer.hits()).isEqualTo(4);
assertThat(cursorTracer.faults()).isEqualTo(1);
}
}
use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.
the class MetaDataStoreTest method tracePageCacheAccessOnGetRecord.
@Test
void tracePageCacheAccessOnGetRecord() throws IOException {
var cacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAccessOnGetRecord"));
try (var metaDataStore = newMetaDataStore()) {
MetaDataStore.getRecord(pageCache, metaDataStore.getStorageFile(), MetaDataStore.Position.RANDOM_NUMBER, databaseLayout.getDatabaseName(), cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isOne();
assertThat(cursorTracer.unpins()).isOne();
assertThat(cursorTracer.hits()).isOne();
}
}
use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.
the class MetaDataStoreTest method tracePageCacheAssessOnIncrementAndGetVersion.
@Test
void tracePageCacheAssessOnIncrementAndGetVersion() {
var cacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("tracePageCacheAssessOnIncrementAndGetVersion"));
try (var metaDataStore = newMetaDataStore()) {
metaDataStore.incrementAndGetVersion(cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(1);
assertThat(cursorTracer.unpins()).isEqualTo(1);
assertThat(cursorTracer.hits()).isEqualTo(1);
}
}
use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.
the class TxStateTransactionDataSnapshotIT method tracePageCacheAccessOnTransactionSnapshotCreation.
@Test
void tracePageCacheAccessOnTransactionSnapshotCreation() {
long nodeId;
long relationshipId;
try (Transaction transaction = database.beginTx()) {
var node1 = transaction.createNode();
var node2 = transaction.createNode();
var relationship = node1.createRelationshipTo(node2, withName("marker"));
node1.setProperty("foo", "bar");
nodeId = node1.getId();
relationshipId = relationship.getId();
transaction.commit();
}
try (Transaction transaction = database.beginTx()) {
transaction.getNodeById(nodeId).delete();
transaction.getRelationshipById(relationshipId).delete();
var kernelTransaction = getKernelTransaction(transaction);
var transactionState = kernelTransaction.txState();
var cursorContext = kernelTransaction.cursorContext();
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
cursorTracer.reportEvents();
try (var snapshot = new TxStateTransactionDataSnapshot(transactionState, kernelTransaction.newStorageReader(), kernelTransaction)) {
// no work for snapshot
}
assertThat(cursorTracer.pins()).isEqualTo(3);
assertThat(cursorTracer.hits()).isEqualTo(3);
assertThat(cursorTracer.unpins()).isEqualTo(3);
}
}
Aggregations