use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.
the class ReadOnlyTransactionIdStoreIT method testPageCacheAccessOnTransactionIdStoreConstruction.
@Test
void testPageCacheAccessOnTransactionIdStoreConstruction() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("testPageCacheAccessOnTransactionIdStoreConstruction"));
new ReadOnlyTransactionIdStore(fs, pageCache, databaseLayout, cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(4);
assertThat(cursorTracer.unpins()).isEqualTo(4);
assertThat(cursorTracer.hits()).isEqualTo(4);
}
use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.
the class TxStateTransactionDataSnapshotIT method assertZeroTracer.
private void assertZeroTracer(CursorContext cursorContext) {
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isZero();
assertThat(cursorTracer.hits()).isZero();
assertThat(cursorTracer.unpins()).isZero();
}
use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer 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.cursor.PageCursorTracer in project neo4j by neo4j.
the class NodeEntityTest method traceNodePageCacheAccessOnRelationshipsAccess.
@Test
void traceNodePageCacheAccessOnRelationshipsAccess() {
long targetId;
var relationshipType = RelationshipType.withName("connection");
try (Transaction tx = db.beginTx()) {
var target = tx.createNode();
for (int i = 0; i < 100; i++) {
tx.createNode().createRelationshipTo(target, relationshipType);
}
targetId = target.getId();
tx.commit();
}
try (Transaction tx = db.beginTx()) {
var cursorContext = ((InternalTransaction) tx).kernelTransaction().cursorContext();
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
var source = tx.getNodeById(targetId);
cursorTracer.reportEvents();
assertZeroTracer(cursorContext);
assertThat(count(source.getRelationships(Direction.INCOMING, relationshipType))).isGreaterThan(0);
assertThat(cursorTracer.hits()).isEqualTo(3);
assertThat(cursorTracer.unpins()).isEqualTo(2);
assertThat(cursorTracer.pins()).isEqualTo(3);
}
}
use of org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer in project neo4j by neo4j.
the class NodeEntityTest method traceNodePageCacheAccessOnDegreeCount.
@Test
void traceNodePageCacheAccessOnDegreeCount() {
long sourceId;
try (Transaction tx = db.beginTx()) {
var source = tx.createNode();
var relationshipType = RelationshipType.withName("connection");
createDenseNodeWithShortIncomingChain(tx, source, relationshipType);
sourceId = source.getId();
tx.commit();
}
try (Transaction tx = db.beginTx()) {
var cursorContext = ((InternalTransaction) tx).kernelTransaction().cursorContext();
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
var source = tx.getNodeById(sourceId);
cursorTracer.reportEvents();
assertZeroTracer(cursorContext);
source.getDegree(Direction.INCOMING);
assertThat(cursorTracer.hits()).isEqualTo(3);
assertThat(cursorTracer.unpins()).isEqualTo(0);
assertThat(cursorTracer.pins()).isEqualTo(3);
}
}
Aggregations