Skip to content

Commit

Permalink
Reduce per tx execution allocations (#7990)
Browse files Browse the repository at this point in the history
Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
  • Loading branch information
benaadams and LukaszRozmej authored Jan 2, 2025
1 parent 5c5c86e commit 14d832c
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 260 deletions.
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Evm.Benchmark/EvmBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void GlobalSetup()
inputData: default
);

_evmState = new EvmState(long.MaxValue, _environment, ExecutionType.TRANSACTION, _stateProvider.TakeSnapshot());
_evmState = EvmState.RentTopLevel(long.MaxValue, ExecutionType.TRANSACTION, _stateProvider.TakeSnapshot(), _environment, new StackAccessTracker());
}

[Benchmark]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void GlobalSetup()
inputData: default
);

_evmState = new EvmState(100_000_000L, _environment, ExecutionType.TRANSACTION, _stateProvider.TakeSnapshot());
_evmState = EvmState.RentTopLevel(100_000_000L, ExecutionType.TRANSACTION, _stateProvider.TakeSnapshot(), _environment, new StackAccessTracker());
}

[Benchmark]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void GlobalSetup()
inputData: default
);

_evmState = new EvmState(100_000_000L, _environment, ExecutionType.TRANSACTION, _stateProvider.TakeSnapshot());
_evmState = EvmState.RentTopLevel(100_000_000L, ExecutionType.TRANSACTION, _stateProvider.TakeSnapshot(), _environment, new StackAccessTracker());
}

[Benchmark(Baseline = true)]
Expand Down
19 changes: 10 additions & 9 deletions src/Nethermind/Nethermind.Evm.Test/EvmStateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,25 +216,26 @@ public void Can_dispose_without_init()
public void Can_dispose_after_init()
{
EvmState evmState = CreateEvmState();
evmState.InitStacks();
evmState.InitializeStacks();
evmState.Dispose();
}

private static EvmState CreateEvmState(EvmState parentEvmState = null, bool isContinuation = false) =>
parentEvmState is null
? new EvmState(10000,
new ExecutionEnvironment(),
ExecutionType.CALL,
Snapshot.Empty)
: new EvmState(10000,
new ExecutionEnvironment(),
? EvmState.RentTopLevel(10000,
ExecutionType.CALL,
Snapshot.Empty,
new ExecutionEnvironment(),
new StackAccessTracker())
: EvmState.RentFrame(10000,
0,
0,
ExecutionType.CALL,
false,
false,
parentEvmState.AccessTracker,
false);
Snapshot.Empty,
new ExecutionEnvironment(),
parentEvmState.AccessTracker);

public class Context { }
}
Expand Down
Loading

0 comments on commit 14d832c

Please sign in to comment.