From 44d31c1ff9d21c3efaf97c91caabf15d94a6ac91 Mon Sep 17 00:00:00 2001 From: Amirul Ashraf Date: Thu, 23 May 2024 19:26:41 +0800 Subject: [PATCH] Log when using larger than default pruning cache (#7066) --- src/Nethermind/Nethermind.Init/InitializeStateDb.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Init/InitializeStateDb.cs b/src/Nethermind/Nethermind.Init/InitializeStateDb.cs index fc448cbc239..55776b2ccb2 100644 --- a/src/Nethermind/Nethermind.Init/InitializeStateDb.cs +++ b/src/Nethermind/Nethermind.Init/InitializeStateDb.cs @@ -74,7 +74,7 @@ public Task Execute(CancellationToken cancellationToken) if (pruningConfig.PruningBoundary < 64) { - if (_logger.IsWarn) _logger.Warn($"Prunig boundary must be at least 64. Setting to 64."); + if (_logger.IsWarn) _logger.Warn($"Pruning boundary must be at least 64. Setting to 64."); pruningConfig.PruningBoundary = 64; } @@ -98,6 +98,12 @@ public Task Execute(CancellationToken cancellationToken) persistenceStrategy = persistenceStrategy.Or(triggerPersistenceStrategy); } + if ((_api.NodeStorageFactory.CurrentKeyScheme != INodeStorage.KeyScheme.Hash || initConfig.StateDbKeyScheme == INodeStorage.KeyScheme.HalfPath) + && pruningConfig.CacheMb > 2000) + { + if (_logger.IsWarn) _logger.Warn($"Detected {pruningConfig.CacheMb}MB of pruning cache config. Pruning cache more than 2000MB is not recommended as it may cause long memory pruning time which affect attestation."); + } + pruningStrategy = Prune .WhenCacheReaches(pruningConfig.CacheMb.MB()) // Use of ratio, as the effectiveness highly correlate with the amount of keys per snapshot save which