Search in sources :

Example 1 with PageCacheTracer

use of org.neo4j.io.pagecache.tracing.PageCacheTracer in project neo4j by neo4j.

the class ConfigurablePageCacheRule method createPageCache.

private PageCache createPageCache(FileSystemAbstraction fs, PageCacheConfig pageCacheConfig, Config config) {
    PageCacheTracer tracer = selectConfig(baseConfig.tracer, pageCacheConfig.tracer, PageCacheTracer.NULL);
    PageCursorTracerSupplier cursorTracerSupplier = selectConfig(baseConfig.pageCursorTracerSupplier, pageCacheConfig.pageCursorTracerSupplier, DefaultPageCursorTracerSupplier.INSTANCE);
    Config finalConfig = config.withDefaults(MapUtil.stringMap(GraphDatabaseSettings.pagecache_memory.name(), "8M"));
    FormattedLogProvider logProvider = FormattedLogProvider.toOutputStream(System.err);
    ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fs, finalConfig, tracer, cursorTracerSupplier, logProvider.getLog(PageCache.class)) {

        @Override
        public int calculatePageSize(Config config, PageSwapperFactory swapperFactory) {
            if (pageCacheConfig.pageSize != null) {
                return pageCacheConfig.pageSize;
            }
            return super.calculatePageSize(config, swapperFactory);
        }
    };
    return pageCacheFactory.getOrCreatePageCache();
}
Also used : PageSwapperFactory(org.neo4j.io.pagecache.PageSwapperFactory) PageCursorTracerSupplier(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier) DefaultPageCursorTracerSupplier(org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracerSupplier) Config(org.neo4j.kernel.configuration.Config) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) ConfiguringPageCacheFactory(org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory) PageCache(org.neo4j.io.pagecache.PageCache) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider)

Example 2 with PageCacheTracer

use of org.neo4j.io.pagecache.tracing.PageCacheTracer in project neo4j by neo4j.

the class BatchingNeoStores method batchingNeoStores.

public static BatchingNeoStores batchingNeoStores(FileSystemAbstraction fileSystem, File storeDir, RecordFormats recordFormats, Configuration config, LogService logService, AdditionalInitialIds initialIds, Config dbConfig) {
    Config neo4jConfig = getNeo4jConfig(config, dbConfig);
    final PageCacheTracer tracer = new DefaultPageCacheTracer();
    PageCache pageCache = createPageCache(fileSystem, neo4jConfig, logService.getInternalLogProvider(), tracer, DefaultPageCursorTracerSupplier.INSTANCE);
    BatchingNeoStores batchingNeoStores = new BatchingNeoStores(fileSystem, pageCache, storeDir, recordFormats, neo4jConfig, logService, initialIds, false, tracer::bytesWritten);
    return batchingNeoStores;
}
Also used : Config(org.neo4j.kernel.configuration.Config) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) PageCache(org.neo4j.io.pagecache.PageCache) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)

Example 3 with PageCacheTracer

use of org.neo4j.io.pagecache.tracing.PageCacheTracer in project neo4j by neo4j.

the class PageCacheCountersIT method pageCacheCountersAreSumOfPageCursorCounters.

@Test
@RepeatRule.Repeat(times = 5)
public void pageCacheCountersAreSumOfPageCursorCounters() throws Exception {
    List<NodeCreator> nodeCreators = new ArrayList<>(numberOfWorkers);
    List<Future> nodeCreatorFutures = new ArrayList<>(numberOfWorkers);
    PageCacheTracer pageCacheTracer = getPageCacheTracer(db);
    long initialPins = pageCacheTracer.pins();
    long initialHits = pageCacheTracer.hits();
    long initialUnpins = pageCacheTracer.unpins();
    long initialBytesRead = pageCacheTracer.bytesRead();
    long initialBytesWritten = pageCacheTracer.bytesWritten();
    long initialEvictions = pageCacheTracer.evictions();
    long initialFaults = pageCacheTracer.faults();
    long initialFlushes = pageCacheTracer.flushes();
    startNodeCreators(nodeCreators, nodeCreatorFutures);
    TimeUnit.MILLISECONDS.sleep(50);
    stopNodeCreators(nodeCreators, nodeCreatorFutures);
    assertThat(pageCacheTracer.pins(), greaterThan(0L));
    assertThat(pageCacheTracer.faults(), greaterThan(0L));
    assertThat(pageCacheTracer.pins(), greaterThan(0L));
    assertThat("Number of pins events in page cache tracer should equal to the sum of pin events in page cursor tracers.", pageCacheTracer.pins(), greaterThanOrEqualTo(sumCounters(nodeCreators, NodeCreator::getPins, initialPins)));
    assertThat("Number of unpins events in page cache tracer should equal to the sum of unpin events in page cursor tracers.", pageCacheTracer.unpins(), greaterThanOrEqualTo(sumCounters(nodeCreators, NodeCreator::getUnpins, initialUnpins)));
    assertThat("Number of initialBytesRead in page cache tracer should equal to the sum of initialBytesRead in page cursor tracers.", pageCacheTracer.bytesRead(), greaterThanOrEqualTo(sumCounters(nodeCreators, NodeCreator::getBytesRead, initialBytesRead)));
    assertThat("Number of bytesWritten in page cache tracer should equal to the sum of bytesWritten in page cursor tracers.", pageCacheTracer.bytesWritten(), greaterThanOrEqualTo(sumCounters(nodeCreators, NodeCreator::getBytesWritten, initialBytesWritten)));
    assertThat("Number of evictions in page cache tracer should equal to the sum of evictions in page cursor tracers.", pageCacheTracer.evictions(), greaterThanOrEqualTo(sumCounters(nodeCreators, NodeCreator::getEvictions, initialEvictions)));
    assertThat("Number of faults in page cache tracer should equal to the sum of faults in " + "page cursor tracers.", pageCacheTracer.faults(), greaterThanOrEqualTo(sumCounters(nodeCreators, NodeCreator::getFaults, initialFaults)));
    assertThat("Number of flushes in page cache tracer should equal to the sum of flushes in page cursor tracers.", pageCacheTracer.flushes(), greaterThanOrEqualTo(sumCounters(nodeCreators, NodeCreator::getFlushes, initialFlushes)));
    assertThat("Number of hits in page cache tracer should equal to the sum of hits in page cursor tracers.", pageCacheTracer.hits(), greaterThanOrEqualTo(sumCounters(nodeCreators, NodeCreator::getHits, initialHits)));
}
Also used : ArrayList(java.util.ArrayList) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) Future(java.util.concurrent.Future) Test(org.junit.Test)

Aggregations

PageCacheTracer (org.neo4j.io.pagecache.tracing.PageCacheTracer)3 PageCache (org.neo4j.io.pagecache.PageCache)2 Config (org.neo4j.kernel.configuration.Config)2 ArrayList (java.util.ArrayList)1 Future (java.util.concurrent.Future)1 Test (org.junit.Test)1 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)1 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)1 DefaultPageCursorTracerSupplier (org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracerSupplier)1 PageCursorTracerSupplier (org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier)1 ConfiguringPageCacheFactory (org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory)1 FormattedLogProvider (org.neo4j.logging.FormattedLogProvider)1