Search in sources :

Example 1 with MuninnPageCache

use of org.neo4j.io.pagecache.impl.muninn.MuninnPageCache in project neo4j by neo4j.

the class CsvInputEstimateCalculationIT method shouldCalculateCorrectEstimates.

@Test
void shouldCalculateCorrectEstimates() throws Exception {
    // given a couple of input files of various layouts
    Input input = generateData();
    RecordFormats format = LATEST_RECORD_FORMATS;
    Input.Estimates estimates = input.calculateEstimates(new PropertyValueRecordSizeCalculator(format.property().getRecordSize(NO_STORE_HEADER), GraphDatabaseInternalSettings.string_block_size.defaultValue(), 0, GraphDatabaseInternalSettings.array_block_size.defaultValue(), 0));
    // when
    Config config = Config.defaults();
    FileSystemAbstraction fs = new DefaultFileSystemAbstraction();
    try (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
        new ParallelBatchImporter(databaseLayout, fs, PageCacheTracer.NULL, PBI_CONFIG, NullLogService.getInstance(), INVISIBLE, EMPTY, config, format, ImportLogic.NO_MONITOR, jobScheduler, Collector.EMPTY, LogFilesInitializer.NULL, IndexImporterFactory.EMPTY, EmptyMemoryTracker.INSTANCE).doImport(input);
        // then compare estimates with actual disk sizes
        SingleFilePageSwapperFactory swapperFactory = new SingleFilePageSwapperFactory(fs);
        try (PageCache pageCache = new MuninnPageCache(swapperFactory, jobScheduler, MuninnPageCache.config(1000));
            NeoStores stores = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable()).openAllNeoStores()) {
            assertRoughlyEqual(estimates.numberOfNodes(), stores.getNodeStore().getNumberOfIdsInUse());
            assertRoughlyEqual(estimates.numberOfRelationships(), stores.getRelationshipStore().getNumberOfIdsInUse());
            assertRoughlyEqual(estimates.numberOfNodeProperties() + estimates.numberOfRelationshipProperties(), calculateNumberOfProperties(stores));
        }
        long measuredPropertyStorage = propertyStorageSize();
        long estimatedPropertyStorage = estimates.sizeOfNodeProperties() + estimates.sizeOfRelationshipProperties();
        assertThat(estimatedPropertyStorage).as("Estimated property storage size of %s must be within 10%% of the measured size of %s.", bytesToString(estimatedPropertyStorage), bytesToString(measuredPropertyStorage)).isCloseTo(measuredPropertyStorage, withPercentage(10.0));
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) ParallelBatchImporter(org.neo4j.internal.batchimport.ParallelBatchImporter) Input(org.neo4j.internal.batchimport.input.Input) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) NeoStores(org.neo4j.kernel.impl.store.NeoStores) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) PropertyValueRecordSizeCalculator(org.neo4j.kernel.impl.store.PropertyValueRecordSizeCalculator) PageCache(org.neo4j.io.pagecache.PageCache) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) Test(org.junit.jupiter.api.Test)

Example 2 with MuninnPageCache

use of org.neo4j.io.pagecache.impl.muninn.MuninnPageCache in project neo4j by neo4j.

the class GBPTreePartialCreateFuzzIT method main.

static void main(String[] args) throws Exception {
    // Just start and immediately close. The process spawning this subprocess will kill it in the middle of all this
    Path file = Path.of(args[0]);
    try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction();
        JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
        SingleFilePageSwapperFactory swapper = new SingleFilePageSwapperFactory(fs);
        try (PageCache pageCache = new MuninnPageCache(swapper, jobScheduler, config(10))) {
            fs.deleteFile(file);
            new GBPTreeBuilder<>(pageCache, file, longLayout().build()).build().close();
        }
    }
}
Also used : Path(java.nio.file.Path) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) JobScheduler(org.neo4j.scheduler.JobScheduler) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) PageCache(org.neo4j.io.pagecache.PageCache) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache)

Example 3 with MuninnPageCache

use of org.neo4j.io.pagecache.impl.muninn.MuninnPageCache in project neo4j by neo4j.

the class LabelsAcceptanceTest method oversteppingMaxNumberOfLabelsShouldFailGracefully.

@Test
void oversteppingMaxNumberOfLabelsShouldFailGracefully() throws IOException {
    JobScheduler scheduler = JobSchedulerFactory.createScheduler();
    try (EphemeralFileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();
        Lifespan lifespan = new Lifespan(scheduler);
        PageCache pageCache = new MuninnPageCache(swapper(fileSystem), scheduler, MuninnPageCache.config(1_000))) {
        // Given
        Dependencies dependencies = new Dependencies();
        dependencies.satisfyDependencies(createIdContextFactoryWithMaxedOutLabelTokenIds(fileSystem, scheduler));
        DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder().setFileSystem(fileSystem).noOpSystemGraphInitializer().setExternalDependencies(dependencies).impermanent().build();
        GraphDatabaseService graphDatabase = managementService.database(DEFAULT_DATABASE_NAME);
        // When
        try (Transaction tx = graphDatabase.beginTx()) {
            assertThrows(ConstraintViolationException.class, () -> tx.createNode().addLabel(Labels.MY_LABEL));
        }
        managementService.shutdown();
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) EphemeralFileSystemAbstraction(org.neo4j.io.fs.EphemeralFileSystemAbstraction) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) Dependencies(org.neo4j.collection.Dependencies) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) PageCache(org.neo4j.io.pagecache.PageCache) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) Test(org.junit.jupiter.api.Test)

Example 4 with MuninnPageCache

use of org.neo4j.io.pagecache.impl.muninn.MuninnPageCache in project neo4j by neo4j.

the class GBPTreeBootstrapper method instantiatePageCache.

private void instantiatePageCache(FileSystemAbstraction fs, JobScheduler jobScheduler, int pageSize) {
    if (pageCache != null && pageCache.pageSize() == pageSize) {
        return;
    }
    closePageCache();
    var swapper = new SingleFilePageSwapperFactory(fs);
    long expectedMemory = Math.max(MuninnPageCache.memoryRequiredForPages(100), 3L * pageSize);
    pageCache = new MuninnPageCache(swapper, jobScheduler, config(createAllocator(expectedMemory, EmptyMemoryTracker.INSTANCE)).pageSize(pageSize));
}
Also used : MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory)

Example 5 with MuninnPageCache

use of org.neo4j.io.pagecache.impl.muninn.MuninnPageCache in project neo4j by neo4j.

the class BatchingNeoStores method createPageCache.

private static PageCache createPageCache(FileSystemAbstraction fileSystem, Config config, PageCacheTracer tracer, JobScheduler jobScheduler, MemoryTracker memoryTracker) {
    SingleFilePageSwapperFactory swapperFactory = new SingleFilePageSwapperFactory(fileSystem);
    MemoryAllocator memoryAllocator = createAllocator(ByteUnit.parse(config.get(pagecache_memory)), memoryTracker);
    MuninnPageCache.Configuration configuration = MuninnPageCache.config(memoryAllocator).pageCacheTracer(tracer).memoryTracker(memoryTracker).bufferFactory(new ConfigurableIOBufferFactory(config, memoryTracker)).faultLockStriping(1 << 11).disableEvictionThread();
    return new MuninnPageCache(swapperFactory, jobScheduler, configuration);
}
Also used : MemoryAllocator(org.neo4j.io.mem.MemoryAllocator) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) ConfigurableIOBufferFactory(org.neo4j.configuration.pagecache.ConfigurableIOBufferFactory)

Aggregations

MuninnPageCache (org.neo4j.io.pagecache.impl.muninn.MuninnPageCache)9 SingleFilePageSwapperFactory (org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory)6 JobScheduler (org.neo4j.scheduler.JobScheduler)5 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)4 PageCache (org.neo4j.io.pagecache.PageCache)4 ThreadPoolJobScheduler (org.neo4j.test.scheduler.ThreadPoolJobScheduler)4 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)3 MemoryAllocator (org.neo4j.io.mem.MemoryAllocator)3 Path (java.nio.file.Path)2 Test (org.junit.jupiter.api.Test)2 ConfigurableIOBufferFactory (org.neo4j.configuration.pagecache.ConfigurableIOBufferFactory)2 EphemeralFileSystemAbstraction (org.neo4j.io.fs.EphemeralFileSystemAbstraction)2 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 HashMap (java.util.HashMap)1 Future (java.util.concurrent.Future)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 RandomAdversary (org.neo4j.adversaries.RandomAdversary)1