Search in sources :

Example 6 with MemoryPools

use of org.neo4j.memory.MemoryPools in project neo4j by neo4j.

the class ConsistencyCheckServiceIntegrationTest method tracePageCacheAccessOnConsistencyCheck.

@Test
void tracePageCacheAccessOnConsistencyCheck() throws ConsistencyCheckIncompleteException {
    prepareDbWithDeletedRelationshipPartOfTheChain();
    ConsistencyCheckService service = new ConsistencyCheckService(new Date());
    var pageCacheTracer = new DefaultPageCacheTracer();
    fixture.close();
    JobScheduler jobScheduler = JobSchedulerFactory.createScheduler();
    ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(testDirectory.getFileSystem(), Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m"), pageCacheTracer, NullLog.getInstance(), jobScheduler, Clocks.nanoClock(), new MemoryPools(false));
    try (Lifespan life = new Lifespan(jobScheduler);
        PageCache pageCache = pageCacheFactory.getOrCreatePageCache()) {
        var result = service.runFullConsistencyCheck(fixture.databaseLayout(), Config.defaults(settings()), ProgressMonitorFactory.NONE, NullLogProvider.getInstance(), testDirectory.getFileSystem(), pageCache, false, ConsistencyFlags.DEFAULT, pageCacheTracer, INSTANCE);
        assertFalse(result.isSuccessful());
        assertThat(pageCacheTracer.pins()).isGreaterThanOrEqualTo(74);
        assertThat(pageCacheTracer.unpins()).isGreaterThanOrEqualTo(74);
        assertThat(pageCacheTracer.hits()).isGreaterThanOrEqualTo(35);
        assertThat(pageCacheTracer.faults()).isGreaterThanOrEqualTo(39);
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) MemoryPools(org.neo4j.memory.MemoryPools) ConfiguringPageCacheFactory(org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) Date(java.util.Date) PageCache(org.neo4j.io.pagecache.PageCache) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 7 with MemoryPools

use of org.neo4j.memory.MemoryPools in project neo4j by neo4j.

the class FullCheckFulltextIndexEmptyDocs method check.

private ConsistencyCheckService.Result check(Config config, DatabaseLayout layout) throws Exception {
    JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
    ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fs, config, NULL, NullLog.getInstance(), jobScheduler, Clocks.nanoClock(), new MemoryPools(config.get(memory_tracking)));
    PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
    ConsistencyCheckService.Result result;
    try {
        result = new ConsistencyCheckService().runFullConsistencyCheck(layout, config, NONE, NullLogProvider.getInstance(), fs, pageCache, DebugContext.NO_DEBUG, layout.databaseDirectory(), DEFAULT, NULL, INSTANCE);
    } finally {
        pageCache.close();
        jobScheduler.close();
    }
    return result;
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) MemoryPools(org.neo4j.memory.MemoryPools) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) ConfiguringPageCacheFactory(org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory) PageCache(org.neo4j.io.pagecache.PageCache)

Example 8 with MemoryPools

use of org.neo4j.memory.MemoryPools in project neo4j by neo4j.

the class ConfiguringPageCacheFactoryTest method createPageCacheWithoutPreallocationEnabled.

@Test
void createPageCacheWithoutPreallocationEnabled() throws IOException {
    Config config = Config.defaults(preallocate_store_files, false);
    ConfiguringPageCacheFactory factory = new ConfiguringPageCacheFactory(fs, config, PageCacheTracer.NULL, NullLog.getInstance(), jobScheduler, Clocks.nanoClock(), new MemoryPools());
    Path testFile = testDirectory.createFile("a");
    try (var cache = factory.getOrCreatePageCache();
        var file = cache.map(testFile, PAGE_SIZE, "foo");
        var io = file.io(1024, PF_SHARED_WRITE_LOCK, NULL)) {
        int bigPageToExpand = 20021;
        assertDoesNotThrow(() -> io.next(bigPageToExpand));
        assertEquals(bigPageToExpand, file.getLastPageId());
    }
}
Also used : Path(java.nio.file.Path) MemoryPools(org.neo4j.memory.MemoryPools) Config(org.neo4j.configuration.Config) Test(org.junit.jupiter.api.Test)

Example 9 with MemoryPools

use of org.neo4j.memory.MemoryPools in project neo4j by neo4j.

the class ForsetiMemoryTrackingTest method setUp.

@BeforeEach
void setUp() {
    memoryPool = new MemoryPools().pool(MemoryGroup.TRANSACTION, 0L, null);
    memoryTracker = new LocalMemoryTracker(memoryPool);
    forsetiLockManager = new ForsetiLockManager(Config.defaults(), Clocks.nanoClock(), ResourceTypes.values());
}
Also used : MemoryPools(org.neo4j.memory.MemoryPools) LocalMemoryTracker(org.neo4j.memory.LocalMemoryTracker) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with MemoryPools

use of org.neo4j.memory.MemoryPools in project neo4j by neo4j.

the class HeapTrackingLongHashSetTest method setUp.

@BeforeEach
void setUp() {
    memoryPool = new MemoryPools().pool(MemoryGroup.TRANSACTION, 0L, null);
    memoryTracker = new LocalMemoryTracker(memoryPool);
}
Also used : MemoryPools(org.neo4j.memory.MemoryPools) LocalMemoryTracker(org.neo4j.memory.LocalMemoryTracker) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MemoryPools (org.neo4j.memory.MemoryPools)19 BeforeEach (org.junit.jupiter.api.BeforeEach)9 LocalMemoryTracker (org.neo4j.memory.LocalMemoryTracker)8 Test (org.junit.jupiter.api.Test)7 PageCache (org.neo4j.io.pagecache.PageCache)6 ConfiguringPageCacheFactory (org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory)5 JobScheduler (org.neo4j.scheduler.JobScheduler)5 Config (org.neo4j.configuration.Config)4 IOException (java.io.IOException)2 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)2 Lifespan (org.neo4j.kernel.lifecycle.Lifespan)2 DirectoryNotEmptyException (java.nio.file.DirectoryNotEmptyException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Stream (java.util.stream.Stream)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1