From 2e6d4c5520da6bf66b8a1ce0658f870b65879ee7 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Fri, 11 Oct 2024 00:43:42 +0200 Subject: [PATCH 1/4] Optimize Tasks collections in .Net 9 --- .../Processing/BlockchainProcessor.cs | 2 +- .../Producers/MultipleBlockProducer.cs | 14 +++++------- .../Encoding/TxDecoderTests.cs | 8 +++---- .../PubSub/CompositePublisher.cs | 22 +++++++------------ .../Nethermind.Db/RocksDbInitializer.cs | 7 +++--- .../Tracing/GethLikeCallTracerTests.cs | 12 +++------- .../NodesLocator.cs | 6 +++-- .../Nethermind.Network/CompositeNodeSource.cs | 9 ++++---- .../Nethermind.Network/PeerManager.cs | 8 ++++--- .../Nethermind.Network/SessionMonitor.cs | 3 ++- .../Trie/TrieNodeRecovery.cs | 6 +++-- .../Nethermind.Trie/BatchedTrieVisitor.cs | 7 +++--- .../Nethermind.Trie/PatriciaTree.cs | 3 +-- .../Nethermind.Trie/Pruning/TrieStore.cs | 6 +++-- 14 files changed, 53 insertions(+), 60 deletions(-) diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockchainProcessor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockchainProcessor.cs index 6598b9798a8..3ecd07927d0 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockchainProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockchainProcessor.cs @@ -167,7 +167,7 @@ public async Task StopAsync(bool processRemainingBlocks = false) _blockQueue.CompleteAdding(); } - await Task.WhenAll((_recoveryTask ?? Task.CompletedTask), (_processorTask ?? Task.CompletedTask)); + await Task.WhenAll(_recoveryTask ?? Task.CompletedTask, _processorTask ?? Task.CompletedTask); if (_logger.IsInfo) _logger.Info("Blockchain Processor shutdown complete.. please wait for all components to close"); } diff --git a/src/Nethermind/Nethermind.Consensus/Producers/MultipleBlockProducer.cs b/src/Nethermind/Nethermind.Consensus/Producers/MultipleBlockProducer.cs index 57836b2e474..13f9f26e28a 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/MultipleBlockProducer.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/MultipleBlockProducer.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using Nethermind.Core; +using Nethermind.Core.Collections; using Nethermind.Evm.Tracing; using Nethermind.Logging; @@ -32,23 +33,20 @@ protected MultipleBlockProducer( public async Task BuildBlock(BlockHeader? parentHeader, IBlockTracer? blockTracer = null, PayloadAttributes? payloadAttributes = null, CancellationToken? token = null) { - Task[] produceTasks = new Task[_blockProducers.Length]; + using ArrayPoolList> produceTasks = new(_blockProducers.Length); for (int i = 0; i < _blockProducers.Length; i++) { T blockProducerInfo = _blockProducers[i]; - if (!blockProducerInfo.Condition.CanProduce(parentHeader)) - { - produceTasks[i] = Task.FromResult(null); - continue; - } - produceTasks[i] = blockProducerInfo.BlockProducer.BuildBlock(parentHeader, blockProducerInfo.BlockTracer, cancellationToken: token); + produceTasks.Add(!blockProducerInfo.Condition.CanProduce(parentHeader!) + ? Task.FromResult(null) + : blockProducerInfo.BlockProducer.BuildBlock(parentHeader, blockProducerInfo.BlockTracer, cancellationToken: token)); } IEnumerable<(Block? Block, T BlockProducer)> blocksWithProducers; try { - Block?[] blocks = await Task.WhenAll(produceTasks); + Block?[] blocks = await Task.WhenAll(produceTasks.AsSpan()); blocksWithProducers = blocks.Zip(_blockProducers); } catch (OperationCanceledException) diff --git a/src/Nethermind/Nethermind.Core.Test/Encoding/TxDecoderTests.cs b/src/Nethermind/Nethermind.Core.Test/Encoding/TxDecoderTests.cs index 2bf4116bab7..00ed095d83a 100644 --- a/src/Nethermind/Nethermind.Core.Test/Encoding/TxDecoderTests.cs +++ b/src/Nethermind/Nethermind.Core.Test/Encoding/TxDecoderTests.cs @@ -82,12 +82,10 @@ public void CanCorrectlyCalculateTxHash_when_called_concurrently((Transaction Tx IEnumerable>>> tasks = Enumerable .Range(0, 32) - .Select((_) => - Task.Factory - .StartNew(() => decodedTx.Hash.Should().Be(expectedHash), - TaskCreationOptions.RunContinuationsAsynchronously)); + .Select(_ => Task.Factory.StartNew(() => decodedTx.Hash.Should().Be(expectedHash), + TaskCreationOptions.RunContinuationsAsynchronously)); - Task.WaitAll(tasks.ToArray()); + Task.WaitAll(tasks); } [TestCaseSource(nameof(TestCaseSource))] diff --git a/src/Nethermind/Nethermind.Core/PubSub/CompositePublisher.cs b/src/Nethermind/Nethermind.Core/PubSub/CompositePublisher.cs index cfb3541fa4b..02e1a8addc5 100644 --- a/src/Nethermind/Nethermind.Core/PubSub/CompositePublisher.cs +++ b/src/Nethermind/Nethermind.Core/PubSub/CompositePublisher.cs @@ -1,34 +1,28 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only +using System; using System.Threading.Tasks; +using Nethermind.Core.Collections; namespace Nethermind.Core.PubSub { - public class CompositePublisher : IPublisher + public class CompositePublisher(params IPublisher[] publishers) : IPublisher { - private readonly IPublisher[] _publishers; - - public CompositePublisher(params IPublisher[] publishers) - { - _publishers = publishers; - } - public async Task PublishAsync(T data) where T : class { - // TODO: .Net 9 stackalloc - Task[] tasks = new Task[_publishers.Length]; - for (int i = 0; i < _publishers.Length; i++) + using ArrayPoolList tasks = new(publishers.Length); + for (int i = 0; i < publishers.Length; i++) { - tasks[i] = _publishers[i].PublishAsync(data); + tasks.Add(publishers[i].PublishAsync(data)); } - await Task.WhenAll(tasks); + await Task.WhenAll(tasks.AsSpan()); } public void Dispose() { - foreach (IPublisher publisher in _publishers) + foreach (IPublisher publisher in publishers) { publisher.Dispose(); } diff --git a/src/Nethermind/Nethermind.Db/RocksDbInitializer.cs b/src/Nethermind/Nethermind.Db/RocksDbInitializer.cs index 9e0e61cf742..26be4d0ff27 100644 --- a/src/Nethermind/Nethermind.Db/RocksDbInitializer.cs +++ b/src/Nethermind/Nethermind.Db/RocksDbInitializer.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Nethermind.Core.Collections; namespace Nethermind.Db { @@ -68,13 +69,13 @@ protected void InitAll() protected async Task InitAllAsync() { - HashSet allInitializers = new(); - foreach (var registration in _registrations) + using ArrayPoolList allInitializers = new(_registrations.Count); + foreach (Action registration in _registrations) { allInitializers.Add(Task.Run(() => registration.Invoke())); } - await Task.WhenAll(allInitializers); + await Task.WhenAll(allInitializers.AsSpan()); } protected static string GetTitleDbName(string dbName) => char.ToUpper(dbName[0]) + dbName[1..]; diff --git a/src/Nethermind/Nethermind.Evm.Test/Tracing/GethLikeCallTracerTests.cs b/src/Nethermind/Nethermind.Evm.Test/Tracing/GethLikeCallTracerTests.cs index af49a60c100..c356ce7adc9 100644 --- a/src/Nethermind/Nethermind.Evm.Test/Tracing/GethLikeCallTracerTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/Tracing/GethLikeCallTracerTests.cs @@ -17,7 +17,7 @@ namespace Nethermind.Evm.Test.Tracing; [TestFixture] public class GethLikeCallTracerTests : VirtualMachineTestsBase { - private static readonly JsonSerializerOptions SerializerOptions = EthereumJsonSerializer.JsonOptionsIndented; + private static readonly JsonSerializerOptions SerializerOptions = new(EthereumJsonSerializer.JsonOptionsIndented) { NewLine = "\n"}; private const string? WithLog = """{"withLog":true}"""; private const string? OnlyTopCall = """{"onlyTopCall":true}"""; private const string? WithLogAndOnlyTopCall = """{"withLog":true,"onlyTopCall":true}"""; @@ -27,14 +27,8 @@ private string ExecuteCallTrace(byte[] code, string? tracerConfig = null) (_, Transaction tx) = PrepareTx(MainnetSpecProvider.CancunActivation, 100000, code); NativeCallTracer tracer = new(tx, GetGethTraceOptions(tracerConfig)); - GethLikeTxTrace callTrace = Execute( - tracer, - code, - MainnetSpecProvider.CancunActivation) - .BuildResult(); - return JsonSerializer.Serialize(callTrace.CustomTracerResult?.Value, SerializerOptions) - // fix for windows, can be done better in .NET 9: https://github.com/dotnet/runtime/issues/84117 - .ReplaceLineEndings("\n"); + GethLikeTxTrace callTrace = Execute(tracer, code, MainnetSpecProvider.CancunActivation).BuildResult(); + return JsonSerializer.Serialize(callTrace.CustomTracerResult?.Value, SerializerOptions); } private static GethTraceOptions GetGethTraceOptions(string? config) => GethTraceOptions.Default with diff --git a/src/Nethermind/Nethermind.Network.Discovery/NodesLocator.cs b/src/Nethermind/Nethermind.Network.Discovery/NodesLocator.cs index ef0a4b3d7f2..254bedef24b 100644 --- a/src/Nethermind/Nethermind.Network.Discovery/NodesLocator.cs +++ b/src/Nethermind/Nethermind.Network.Discovery/NodesLocator.cs @@ -3,7 +3,9 @@ using System.Text; using Nethermind.Core; +using Nethermind.Core.Collections; using Nethermind.Core.Crypto; +using Nethermind.Core.Extensions; using Nethermind.Logging; using Nethermind.Network.Discovery.Lifecycle; using Nethermind.Network.Discovery.Messages; @@ -128,8 +130,8 @@ public async Task LocateNodesAsync(byte[]? searchedNodeId, CancellationToken can int count = failRequestCount > 0 ? failRequestCount : _discoveryConfig.Concurrency; IEnumerable nodesToSend = tryCandidates.Skip(nodesTriedCount).Take(count); - IEnumerable> sendFindNodeTasks = SendFindNodes(searchedNodeId, nodesToSend, alreadyTriedNodes); - Result?[] results = await Task.WhenAll(sendFindNodeTasks); + using ArrayPoolList> sendFindNodeTasks = SendFindNodes(searchedNodeId, nodesToSend, alreadyTriedNodes).ToPooledList(count); + Result[] results = await Task.WhenAll(sendFindNodeTasks.AsSpan()); if (results.Length == 0) { diff --git a/src/Nethermind/Nethermind.Network/CompositeNodeSource.cs b/src/Nethermind/Nethermind.Network/CompositeNodeSource.cs index 1402ebcf725..811eb1c3a81 100644 --- a/src/Nethermind/Nethermind.Network/CompositeNodeSource.cs +++ b/src/Nethermind/Nethermind.Network/CompositeNodeSource.cs @@ -8,6 +8,8 @@ using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; +using Nethermind.Core.Collections; +using Nethermind.Core.Extensions; using Nethermind.Stats.Model; namespace Nethermind.Network; @@ -20,14 +22,13 @@ public async IAsyncEnumerable DiscoverNodes([EnumeratorCancellation] Cance { Channel ch = Channel.CreateBounded(1); - // TODO: .Net 9 stackalloc - Task[] feedTasks = _nodeSources.Select(async innerSource => + using ArrayPoolList feedTasks = _nodeSources.Select(async innerSource => { await foreach (Node node in innerSource.DiscoverNodes(cancellationToken)) { await ch.Writer.WriteAsync(node, cancellationToken); } - }).ToArray(); + }).ToPooledList(_nodeSources.Length * 16); try { @@ -38,7 +39,7 @@ public async IAsyncEnumerable DiscoverNodes([EnumeratorCancellation] Cance } finally { - await Task.WhenAll(feedTasks); + await Task.WhenAll(feedTasks.AsSpan()); } } diff --git a/src/Nethermind/Nethermind.Network/PeerManager.cs b/src/Nethermind/Nethermind.Network/PeerManager.cs index 360c2101c50..8a31475d283 100644 --- a/src/Nethermind/Nethermind.Network/PeerManager.cs +++ b/src/Nethermind/Nethermind.Network/PeerManager.cs @@ -12,7 +12,9 @@ using FastEnumUtility; using Nethermind.Core; using Nethermind.Core.Attributes; +using Nethermind.Core.Collections; using Nethermind.Core.Crypto; +using Nethermind.Core.Extensions; using Nethermind.Logging; using Nethermind.Network.Config; using Nethermind.Network.P2P; @@ -206,7 +208,7 @@ private class CandidateSelection private async Task RunPeerUpdateLoop() { Channel taskChannel = Channel.CreateBounded(1); - List? tasks = Enumerable.Range(0, _outgoingConnectParallelism).Select(async (idx) => + using ArrayPoolList tasks = Enumerable.Range(0, _outgoingConnectParallelism).Select(async idx => { await foreach (Peer peer in taskChannel.Reader.ReadAllAsync(_cancellationTokenSource.Token)) { @@ -226,7 +228,7 @@ private async Task RunPeerUpdateLoop() } } if (_logger.IsDebug) _logger.Debug($"Connect worker {idx} completed"); - }).ToList(); + }).ToPooledList(_outgoingConnectParallelism); int loopCount = 0; long previousActivePeersCount = 0; @@ -359,7 +361,7 @@ private async Task RunPeerUpdateLoop() } taskChannel.Writer.Complete(); - await Task.WhenAll(tasks); + await Task.WhenAll(tasks.AsSpan()); } private bool EnsureAvailableActivePeerSlot() diff --git a/src/Nethermind/Nethermind.Network/SessionMonitor.cs b/src/Nethermind/Nethermind.Network/SessionMonitor.cs index 0c2f73f2fbc..11ae1942a5e 100644 --- a/src/Nethermind/Nethermind.Network/SessionMonitor.cs +++ b/src/Nethermind/Nethermind.Network/SessionMonitor.cs @@ -5,6 +5,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; @@ -84,7 +85,7 @@ private async Task SendPingMessagesAsync() if (_pingTasks.Count > 0) { - bool[] tasks = await Task.WhenAll(_pingTasks); + bool[] tasks = await Task.WhenAll(CollectionsMarshal.AsSpan(_pingTasks)); int tasksLength = tasks.Length; if (tasksLength != 0) { diff --git a/src/Nethermind/Nethermind.Synchronization/Trie/TrieNodeRecovery.cs b/src/Nethermind/Nethermind.Synchronization/Trie/TrieNodeRecovery.cs index fa1c10d99ec..85c20a2da21 100644 --- a/src/Nethermind/Nethermind.Synchronization/Trie/TrieNodeRecovery.cs +++ b/src/Nethermind/Nethermind.Synchronization/Trie/TrieNodeRecovery.cs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LGPL-3.0-only using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -47,7 +48,8 @@ protected TrieNodeRecovery(ISyncPeerPool syncPeerPool, ILogManager? logManager) { while (keyRecoveries.Count > 0) { - Task<(Recovery, byte[]?)> task = await Task.WhenAny(keyRecoveries.Select(kr => kr.Task!)); + using ArrayPoolList>? tasks = keyRecoveries.Select(kr => kr.Task!).ToPooledList(keyRecoveries.Count); + Task<(Recovery, byte[]?)> task = await Task.WhenAny<(Recovery, byte[]?)>(tasks.AsSpan()); (Recovery Recovery, byte[]? Data) result = await task; if (result.Data is null) { @@ -57,7 +59,7 @@ protected TrieNodeRecovery(ISyncPeerPool syncPeerPool, ILogManager? logManager) else { if (_logger.IsWarn) _logger.Warn($"Successfully recovered from peer {result.Recovery.Peer} with {result.Data.Length} bytes!"); - cts.Cancel(); + await cts.CancelAsync(); return result.Data; } } diff --git a/src/Nethermind/Nethermind.Trie/BatchedTrieVisitor.cs b/src/Nethermind/Nethermind.Trie/BatchedTrieVisitor.cs index 99bff648354..2cfc57b4556 100644 --- a/src/Nethermind/Nethermind.Trie/BatchedTrieVisitor.cs +++ b/src/Nethermind/Nethermind.Trie/BatchedTrieVisitor.cs @@ -142,12 +142,11 @@ public void Start( try { - // TODO: .Net 9 stackalloc - Task[]? tasks = Enumerable.Range(0, trieVisitContext.MaxDegreeOfParallelism) + using ArrayPoolList tasks = Enumerable.Range(0, trieVisitContext.MaxDegreeOfParallelism) .Select(_ => Task.Run(BatchedThread)) - .ToArray(); + .ToPooledList(trieVisitContext.MaxDegreeOfParallelism); - Task.WaitAll(tasks); + Task.WaitAll(tasks.AsSpan()); } catch (Exception) { diff --git a/src/Nethermind/Nethermind.Trie/PatriciaTree.cs b/src/Nethermind/Nethermind.Trie/PatriciaTree.cs index 88b443a3983..6380da3aa2a 100644 --- a/src/Nethermind/Nethermind.Trie/PatriciaTree.cs +++ b/src/Nethermind/Nethermind.Trie/PatriciaTree.cs @@ -207,7 +207,6 @@ Task CreateTaskForPath(TreePath childPath, TrieNode childNode, int idx) => Task. committer.ReturnConcurrencyQuota(); }); - // TODO: .Net 9 stackalloc ArrayPoolList? childTasks = null; for (int i = 0; i < 16; i++) @@ -240,7 +239,7 @@ Task CreateTaskForPath(TreePath childPath, TrieNode childNode, int idx) => Task. if (childTasks is not null) { - Task.WaitAll(childTasks.ToArray()); + Task.WaitAll(childTasks.AsSpan()); childTasks.Dispose(); } } diff --git a/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs b/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs index 6ae6ca164fc..f5e3caa9c6a 100644 --- a/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs +++ b/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs @@ -797,11 +797,13 @@ void TopLevelPersist(TrieNode tn, Hash256? address2, TreePath path) }); } - Task.WaitAll(parallelStartNodes.Select(entry => Task.Run(() => + using ArrayPoolList tasks = parallelStartNodes.Select(entry => Task.Run(() => { (TrieNode trieNode, Hash256? address2, TreePath path2) = entry; PersistNodeStartingFrom(trieNode, address2, path2, commitSet, persistedNodeRecorder, writeFlags, disposeQueue); - })).ToArray()); + })).ToPooledList(parallelStartNodes.Count); + + Task.WaitAll(tasks.AsSpan()); disposeQueue.CompleteAdding(); Task.WaitAll(_disposeTasks); From 351b80ad8bdbb1dbb07754f4ae9263a1e85832f7 Mon Sep 17 00:00:00 2001 From: "lukasz.rozmej" Date: Fri, 11 Oct 2024 00:51:57 +0200 Subject: [PATCH 2/4] use in test --- .../Nethermind.Core.Test/Encoding/TxDecoderTests.cs | 11 ++++++----- .../Tracing/GethLikeCallTracerTests.cs | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Nethermind/Nethermind.Core.Test/Encoding/TxDecoderTests.cs b/src/Nethermind/Nethermind.Core.Test/Encoding/TxDecoderTests.cs index 00ed095d83a..6d441e08f17 100644 --- a/src/Nethermind/Nethermind.Core.Test/Encoding/TxDecoderTests.cs +++ b/src/Nethermind/Nethermind.Core.Test/Encoding/TxDecoderTests.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using FluentAssertions; using FluentAssertions.Numeric; +using Nethermind.Core.Collections; using Nethermind.Core.Crypto; using Nethermind.Core.Eip2930; using Nethermind.Core.Extensions; @@ -68,7 +69,7 @@ public class TxDecoderTests [TestCaseSource(nameof(TestCaseSource))] [Repeat(10)] // Might wanna increase this to double check when changing logic as on lower value, it does not reproduce. - public void CanCorrectlyCalculateTxHash_when_called_concurrently((Transaction Tx, string Description) testCase) + public async Task CanCorrectlyCalculateTxHash_when_called_concurrently((Transaction Tx, string Description) testCase) { Transaction tx = testCase.Tx; @@ -80,12 +81,12 @@ public void CanCorrectlyCalculateTxHash_when_called_concurrently((Transaction Tx decodedTx.SetPreHash(rlp.Bytes); - IEnumerable>>> tasks = Enumerable + using ArrayPoolList>>> tasks = Enumerable .Range(0, 32) - .Select(_ => Task.Factory.StartNew(() => decodedTx.Hash.Should().Be(expectedHash), - TaskCreationOptions.RunContinuationsAsynchronously)); + .Select(_ => Task.Factory.StartNew(() => decodedTx.Hash.Should().Be(expectedHash), TaskCreationOptions.RunContinuationsAsynchronously)) + .ToPooledList(32); - Task.WaitAll(tasks); + await Task.WhenAll>>(tasks.AsSpan()); } [TestCaseSource(nameof(TestCaseSource))] diff --git a/src/Nethermind/Nethermind.Evm.Test/Tracing/GethLikeCallTracerTests.cs b/src/Nethermind/Nethermind.Evm.Test/Tracing/GethLikeCallTracerTests.cs index c356ce7adc9..10eea16fa7a 100644 --- a/src/Nethermind/Nethermind.Evm.Test/Tracing/GethLikeCallTracerTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/Tracing/GethLikeCallTracerTests.cs @@ -17,7 +17,7 @@ namespace Nethermind.Evm.Test.Tracing; [TestFixture] public class GethLikeCallTracerTests : VirtualMachineTestsBase { - private static readonly JsonSerializerOptions SerializerOptions = new(EthereumJsonSerializer.JsonOptionsIndented) { NewLine = "\n"}; + private static readonly JsonSerializerOptions SerializerOptions = new(EthereumJsonSerializer.JsonOptionsIndented) { NewLine = "\n" }; private const string? WithLog = """{"withLog":true}"""; private const string? OnlyTopCall = """{"onlyTopCall":true}"""; private const string? WithLogAndOnlyTopCall = """{"withLog":true,"onlyTopCall":true}"""; From da5da85575b0c84f12bf8791ca367ff86cae4d5f Mon Sep 17 00:00:00 2001 From: Amirul Ashraf Date: Fri, 18 Oct 2024 08:17:45 +0800 Subject: [PATCH 3/4] Use span --- src/Nethermind/Nethermind.State/PersistentStorageProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.State/PersistentStorageProvider.cs b/src/Nethermind/Nethermind.State/PersistentStorageProvider.cs index 5af8d6aa374..b1b418037b2 100644 --- a/src/Nethermind/Nethermind.State/PersistentStorageProvider.cs +++ b/src/Nethermind/Nethermind.State/PersistentStorageProvider.cs @@ -347,7 +347,7 @@ public void CommitTrees(IBlockCommitter blockCommitter) } } - Task.WaitAll(commitTask); + Task.WaitAll(commitTask.AsSpan()); _toUpdateRoots.Clear(); // only needed here as there is no control over cached storage size otherwise From 3eb0e3b913e17f20c32b23f8e4088a102e4aaaa0 Mon Sep 17 00:00:00 2001 From: Amirul Ashraf Date: Fri, 18 Oct 2024 08:22:42 +0800 Subject: [PATCH 4/4] Fix build --- src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs b/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs index 43bb8c2001d..d2c19e70b56 100644 --- a/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs +++ b/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs @@ -776,7 +776,7 @@ void TopLevelPersist(TrieNode tn, Hash256? address2, TreePath path) using ArrayPoolList tasks = parallelStartNodes.Select(entry => Task.Run(() => { (TrieNode trieNode, Hash256? address2, TreePath path2) = entry; - PersistNodeStartingFrom(trieNode, address2, path2, commitSet, persistedNodeRecorder, writeFlags, disposeQueue); + PersistNodeStartingFrom(trieNode, address2, path2, persistedNodeRecorder, writeFlags, disposeQueue); })).ToPooledList(parallelStartNodes.Count); Task.WaitAll(tasks.AsSpan());