Skip to content

Commit

Permalink
Re Add Malloc Trim (#7587)
Browse files Browse the repository at this point in the history
(cherry picked from commit 4b1084a)
  • Loading branch information
benaadams authored and MarekM25 committed Oct 16, 2024
1 parent 10412d1 commit d068f62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/Nethermind/Nethermind.Consensus/GC/GCScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Runtime;
using System.Threading;
using System.Threading.Tasks;
using Nethermind.Core.Extensions;
using Nethermind.Core.Memory;

namespace Nethermind.Consensus;

Expand Down Expand Up @@ -180,7 +182,8 @@ public bool GCCollect(int generation, GCCollectionMode mode, bool blocking, bool
// Reset the block counter after GC
_countToGC = MaxBlocksWithoutGC;
System.GC.Collect(generation, mode, blocking: blocking, compacting: compacting);

// Also trim native memory used by Db
MallocHelper.Instance.MallocTrim((uint)1.MiB());
// Indicate that GC has finished
MarkGCResumed();

Expand Down
5 changes: 2 additions & 3 deletions src/Nethermind/Nethermind.Merge.Plugin/GC/GCKeeper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using FastEnumUtility;
using Nethermind.Consensus;
using Nethermind.Core.Extensions;
using Nethermind.Core.Memory;
using Nethermind.Logging;

namespace Nethermind.Merge.Plugin.GC;
Expand Down Expand Up @@ -150,8 +149,8 @@ private async Task ScheduleGCInternal()
{
// This should give time to finalize response in Engine API
// Normally we should get block every 12s (5s on some chains)
// Lets say we process block in 2s, then delay 500ms, then invoke GC
await Task.Delay(500);
// Lets say we process block in 2s, then delay 125ms, then invoke GC
await Task.Delay(125);

if (GCSettings.LatencyMode != GCLatencyMode.NoGCRegion)
{
Expand Down

0 comments on commit d068f62

Please sign in to comment.