Skip to content

Commit

Permalink
Remove parallel from withdrawal warmup (#7153)
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored and kamilchodola committed Jun 10, 2024
1 parent 752cf12 commit 7aa575a
Showing 1 changed file with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,33 @@ void WarmupWithdrawals(ParallelOptions parallelOptions, IReleaseSpec spec, Block
{
if (spec.WithdrawalsEnabled && block.Withdrawals is not null)
{
Parallel.For(0, block.Withdrawals.Length, parallelOptions,
i =>
ReadOnlyTxProcessingEnv env = _envPool.Get();
try
{
foreach (Withdrawal withdrawal in block.Withdrawals)
{
ReadOnlyTxProcessingEnv env = _envPool.Get();
try
{
env.StateProvider.WarmUp(block.Withdrawals[i].Address);
}
catch (Exception ex)
{
if (_logger.IsDebug) _logger.Error($"Error pre-warming withdrawal {i}", ex);
}
finally
{
env.Reset();
_envPool.Return(env);
}
});
if (parallelOptions.CancellationToken.IsCancellationRequested) return;

env.StateProvider.WarmUp(withdrawal.Address);
}
}
catch (Exception ex)
{
if (_logger.IsDebug) _logger.Error($"Error pre-warming withdrawals", ex);
}
finally
{
env.Reset();
_envPool.Return(env);
}
}
}

void WarmupTransactions(ParallelOptions parallelOptions, IReleaseSpec spec, Block block, Hash256 stateRoot)
{
Parallel.For(0, block.Transactions.Length, parallelOptions, i =>
if (parallelOptions.CancellationToken.IsCancellationRequested) return;

Parallel.For(0, block.Transactions.Length, parallelOptions, (i) =>
{
// If the transaction has already been processed or being processed, exit early
if (block.TransactionProcessed >= i) return;
Expand Down

0 comments on commit 7aa575a

Please sign in to comment.