use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ConfigurableStandalonePageCacheFactoryTest method mustAutomaticallyStartEvictionThread.
@Test(timeout = 10000)
public void mustAutomaticallyStartEvictionThread() throws IOException {
try (FileSystemAbstraction fs = new DelegateFileSystemAbstraction(Jimfs.newFileSystem(jimConfig()))) {
File file = new File("/a").getCanonicalFile();
fs.create(file).close();
try (PageCache cache = ConfigurableStandalonePageCacheFactory.createPageCache(fs);
PagedFile pf = cache.map(file, 4096);
PageCursor cursor = pf.io(0, PagedFile.PF_SHARED_WRITE_LOCK)) {
// If the eviction thread has not been started, then this test will block forever.
for (int i = 0; i < 10_000; i++) {
assertTrue(cursor.next());
cursor.putInt(42);
}
}
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ConfiguringPageCacheFactoryTest method mustIgnoreExplicitlySpecifiedCachePageSizeIfPageSwapperHintIsStrict.
@Test
public void mustIgnoreExplicitlySpecifiedCachePageSizeIfPageSwapperHintIsStrict() throws Exception {
// Given
int cachePageSizeHint = 16 * 1024;
PageSwapperFactoryForTesting.cachePageSizeHint.set(cachePageSizeHint);
PageSwapperFactoryForTesting.cachePageSizeHintIsStrict.set(true);
Config config = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.pagecache_swapper.name(), TEST_PAGESWAPPER_NAME));
// When
ConfiguringPageCacheFactory factory = new ConfiguringPageCacheFactory(fsRule.get(), config, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, NullLog.getInstance());
// Then
try (PageCache cache = factory.getOrCreatePageCache()) {
assertThat(cache.pageSize(), is(cachePageSizeHint));
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ConfiguringPageCacheFactoryTest method shouldFitAsManyPagesAsItCan.
@Test
public void shouldFitAsManyPagesAsItCan() throws Throwable {
// Given
final int pageSize = 8192;
final int maxPages = 60;
Config config = Config.embeddedDefaults(stringMap(pagecache_memory.name(), Integer.toString(pageSize * maxPages)));
// When
ConfiguringPageCacheFactory factory = new ConfiguringPageCacheFactory(fsRule.get(), config, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, NullLog.getInstance());
// Then
try (PageCache cache = factory.getOrCreatePageCache()) {
assertThat(cache.pageSize(), equalTo(pageSize));
assertThat(cache.maxCachedPages(), equalTo(maxPages));
}
}
use of org.neo4j.io.pagecache.PageCache 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();
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class BatchInserterImplTest method testHonorsPassedInParams.
@Test
public void testHonorsPassedInParams() throws Exception {
BatchInserter inserter = BatchInserters.inserter(testDirectory.graphDbDir(), fileSystemRule.get(), stringMap(GraphDatabaseSettings.pagecache_memory.name(), "280K"));
NeoStores neoStores = ReflectionUtil.getPrivateField(inserter, "neoStores", NeoStores.class);
PageCache pageCache = ReflectionUtil.getPrivateField(neoStores, "pageCache", PageCache.class);
inserter.shutdown();
int mappedMemoryTotalSize = pageCache.maxCachedPages() * pageCache.pageSize();
assertThat("memory mapped config is active", mappedMemoryTotalSize, is(280 * 1024));
}
Aggregations