Skip to content

Commit cb0c8db

Browse files
committed
writeMemory: avoid repeated small expansions of memory on concrete case
1 parent ca87869 commit cb0c8db

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: src/EVM.hs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2953,7 +2953,10 @@ writeMemory memory offset buf = do
29532953
expandMemory targetSize = do
29542954
let toAlloc = targetSize - VUnboxed.Mutable.length memory
29552955
if toAlloc > 0 then do
2956-
memory' <- VUnboxed.Mutable.grow memory toAlloc
2956+
-- always grow at least 8k, to avoid the performance impact
2957+
-- that would happen with repeated small expansion operations,
2958+
-- as grow does a larger *copy* of the vector on a new place
2959+
memory' <- VUnboxed.Mutable.grow memory $ max toAlloc 8192
29572960
assign (#state % #memory) (ConcreteMemory memory')
29582961
pure memory'
29592962
else

0 commit comments

Comments
 (0)