Ejemplo n.º 1
0
        public void Netty_arena_order_is_configured_correctly(ulong memoryHint, uint cpuCount, int expectedArenaOrder)
        {
            MemoryHintMan memoryHintMan = new MemoryHintMan(LimboLogs.Instance);
            NetworkConfig networkConfig = new NetworkConfig();

            memoryHintMan.UpdateNetworkConfig(memoryHint, cpuCount, networkConfig);
            networkConfig.NettyArenaOrder.Should().Be(expectedArenaOrder);
        }
Ejemplo n.º 2
0
        public void Incorrect_input_throws(ulong memoryHint, uint cpuCount)
        {
            MemoryHintMan memoryHintMan = new MemoryHintMan(LimboLogs.Instance);
            NetworkConfig networkConfig = new NetworkConfig();

            Assert.Throws <ArgumentOutOfRangeException>(
                () => memoryHintMan.UpdateNetworkConfig(memoryHint, cpuCount, networkConfig));
        }
Ejemplo n.º 3
0
 public void Setup()
 {
     _dbConfig      = new DbConfig();
     _syncConfig    = new SyncConfig();
     _initConfig    = new InitConfig();
     _txPoolConfig  = new TxPoolConfig();
     _networkConfig = new NetworkConfig();
     _memoryHintMan = new MemoryHintMan(LimboLogs.Instance);
 }
Ejemplo n.º 4
0
        public void Db_size_are_computed_correctly(
            [Values(256 * MB, 512 * MB, 1 * GB, 4 * GB, 6 * GB, 16 * GB, 32 * GB, 64 * GB, 128 * GB)]
            ulong memoryHint,
            [Values(1u, 2u, 3u, 4u, 8u, 32u)] uint cpuCount,
            [Values(true, false)] bool fastSync,
            [Values(true, false)] bool fastBlocks)
        {
            // OK to throw here
            if (memoryHint == 256.MB() && cpuCount >= 8u)
            {
                return;
            }

            MemoryHintMan memoryHintMan = new MemoryHintMan(LimboLogs.Instance);
            SyncConfig    syncConfig    = new SyncConfig();

            syncConfig.FastSync   = fastSync;
            syncConfig.FastBlocks = fastBlocks;

            DbConfig dbConfig = new DbConfig();

            memoryHintMan.UpdateDbConfig(memoryHint, cpuCount, syncConfig, dbConfig);

            ulong totalForHeaders = dbConfig.HeadersDbBlockCacheSize
                                    + dbConfig.HeadersDbWriteBufferNumber * dbConfig.HeadersDbWriteBufferSize;

            ulong totalForBlocks = dbConfig.BlocksDbBlockCacheSize
                                   + dbConfig.BlocksDbWriteBufferNumber * dbConfig.BlocksDbWriteBufferSize;

            ulong totalForInfos = dbConfig.BlockInfosDbBlockCacheSize
                                  + dbConfig.BlockInfosDbWriteBufferNumber * dbConfig.BlockInfosDbWriteBufferSize;

            ulong totalForReceipts = dbConfig.ReceiptsDbBlockCacheSize
                                     + dbConfig.ReceiptsDbWriteBufferNumber * dbConfig.ReceiptsDbWriteBufferSize;

            ulong totalForCode = dbConfig.CodeDbBlockCacheSize
                                 + dbConfig.CodeDbWriteBufferNumber * dbConfig.CodeDbWriteBufferSize;

            ulong totalForPending = dbConfig.PendingTxsDbBlockCacheSize
                                    + dbConfig.PendingTxsDbWriteBufferNumber * dbConfig.PendingTxsDbWriteBufferSize;

            ulong totalMem = (dbConfig.BlockCacheSize + dbConfig.WriteBufferNumber * dbConfig.WriteBufferSize)
                             + totalForHeaders
                             + totalForBlocks
                             + totalForInfos
                             + totalForReceipts
                             + totalForCode
                             + totalForPending;

            // some rounding differences are OK
            totalMem.Should().BeGreaterThan((ulong)(memoryHint * 0.95m) - 2 * MB);
            totalMem.Should().BeLessThan((ulong)(memoryHint * 0.95m) + 2 * MB);
        }
Ejemplo n.º 5
0
        public void Will_not_change_non_default_arena_order(ulong memoryHint, uint cpuCount, int differenceFromDefault)
        {
            MemoryHintMan memoryHintMan = new MemoryHintMan(LimboLogs.Instance);
            NetworkConfig networkConfig = new NetworkConfig();
            int           manuallyConfiguredArenaOrder = INetworkConfig.DefaultNettyArenaOrder + differenceFromDefault;

            networkConfig.NettyArenaOrder = manuallyConfiguredArenaOrder;

            memoryHintMan.UpdateNetworkConfig(memoryHint, cpuCount, networkConfig);

            networkConfig.NettyArenaOrder.Should().Be(manuallyConfiguredArenaOrder);
        }
Ejemplo n.º 6
0
        public Task Execute(CancellationToken _)
        {
            MemoryHintMan memoryHintMan = new MemoryHintMan(_context.LogManager);
            uint          cpuCount      = (uint)Environment.ProcessorCount;

            if (_initConfig.MemoryHint.HasValue)
            {
                if (_initConfig.DiagnosticMode != DiagnosticMode.MemDb)
                {
                    memoryHintMan.UpdateDbConfig((ulong)_initConfig.MemoryHint.Value, cpuCount, _syncConfig, _dbConfig);
                }

                memoryHintMan.UpdateNetworkConfig((ulong)_initConfig.MemoryHint.Value, cpuCount, _networkConfig);
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 7
0
        public Task Execute(CancellationToken _)
        {
            MemoryHintMan memoryHintMan = new MemoryHintMan(_api.LogManager);
            uint          cpuCount      = (uint)Environment.ProcessorCount;

            if (_initConfig.MemoryHint.HasValue)
            {
                memoryHintMan.SetMemoryAllowances(
                    _dbConfig,
                    _initConfig,
                    _networkConfig,
                    _syncConfig,
                    _txPoolConfig,
                    cpuCount);
            }

            return(Task.CompletedTask);
        }