Severe scaling issues with `waintUntilSlot` in emulator
MaximilianAlgehed opened this issue · comments
Summary
We have run into some scalability issues with running big QuickCheck tests in the emulator and I have identified at least one clear cause, Plutus.Trace.Emulator.waitUntilSlot
. Basically, the more slots you wait in this action the more memory the emulator consumes - by a large factor. This happens even if Trace.waitUntilSlot
is the only thing you do in your emulator tests!
Steps to reproduce the behavior
The following test code reveals the problem (for different values of n
):
module Test where
import Test.Tasty
import Plutus.Trace.Emulator as Trace
import Plutus.Contract.Test
main = defaultMain $ testGroup "tests" [
checkPredicate "test"
(walletFundsChange w1 mempty
.&&. walletFundsChange w2 mempty
.&&. walletFundsChange w3 mempty)
$ void $ Trace.waitUntilSlot n]
Actual Result
We see the following performance when running the code:
Wait time (n) | time to execute test
31 0.02s
310 0.11s
3100 0.92s
31000 9.80s
310000 {Ran out of memory at 16GB}
Expected Result
We expect the runtime and memory consumption to not depend in any meaningful way on the number of slots waited.
Describe the approach you would take to fix this
No response
System info
OS: Windows with WSL2
Plutus version: main
Machine: ThinkPad X1 with 11th gen i7 and 32GB internal memory (of which 16GB allocated to WSL2)
@sjoerdvisscher suggested that this may be an issue with the scheduler:
https://github.com/input-output-hk/plutus-apps/blob/SCP-3073-emulated-ledger/plutus-contract/src/Plutus/Trace/Scheduler.hs