use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class CommitProcessTracingIT method tracePageCacheAccessOnCommandCreation.
@Test
void tracePageCacheAccessOnCommandCreation() throws KernelException {
long sourceId;
try (Transaction transaction = database.beginTx()) {
sourceId = transaction.createNode(Label.label("a")).getId();
transaction.commit();
}
var pageCacheTracer = new DefaultPageCacheTracer();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnCommandCreation"));
var reader = storageEngine.newReader()) {
assertZeroCursor(cursorContext);
try (CommandCreationContext context = storageEngine.newCommandCreationContext(INSTANCE)) {
context.initialize(cursorContext);
List<StorageCommand> commands = new ArrayList<>();
var txState = new TxState();
txState.nodeDoAddLabel(1, sourceId);
storageEngine.createCommands(commands, txState, reader, context, IGNORE, LockTracer.NONE, 0, NO_DECORATION, cursorContext, INSTANCE);
}
assertCursor(cursorContext, 2);
}
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer 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.DefaultPageCacheTracer 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.DefaultPageCacheTracer in project neo4j by neo4j.
the class GBPTreeTest method trackPageCacheAccessOnTreeSeek.
@Test
void trackPageCacheAccessOnTreeSeek() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
try (PageCache pageCache = createPageCache((int) ByteUnit.kibiBytes(4));
var tree = index(pageCache).with(pageCacheTracer).build()) {
for (int i = 0; i < 1000; i++) {
insert(tree, i, 1);
}
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("trackPageCacheAccessOnTreeSeek"));
try (var seeker = tree.seek(new MutableLong(0), new MutableLong(Integer.MAX_VALUE), cursorContext)) {
while (seeker.next()) {
// just scroll over the results
}
}
var cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.hits()).isEqualTo(8);
assertThat(cursorTracer.unpins()).isEqualTo(8);
assertThat(cursorTracer.pins()).isEqualTo(8);
assertThat(cursorTracer.faults()).isEqualTo(0);
}
}
use of org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer in project neo4j by neo4j.
the class GBPTreeTest method shouldNotFlushPagedFileIfDeleteOnClose.
@Test
void shouldNotFlushPagedFileIfDeleteOnClose() throws IOException {
// GIVEN
var tracer = new DefaultPageCacheTracer();
try (PageCache pageCache = pageCacheExtension.getPageCache(fileSystem, config().withTracer(tracer))) {
// WHEN
// Closing tree we should see flush happen
long flushesBeforeClose;
try (GBPTree<MutableLong, MutableLong> index = index(pageCache).build()) {
index.setDeleteOnClose(false);
flushesBeforeClose = tracer.flushes();
}
// THEN
assertThat(tracer.flushes()).isGreaterThan(flushesBeforeClose);
// Closing with set delete on close we should see no flush
try (GBPTree<MutableLong, MutableLong> index = index(pageCache).build()) {
index.setDeleteOnClose(true);
flushesBeforeClose = tracer.flushes();
}
// THEN
assertThat(tracer.flushes()).isEqualTo(flushesBeforeClose);
}
}
Aggregations