-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(anvil
): memory / storage leak in long running test against Anvil
#3478
Comments
we keep the entire state in memory but cache history states on disk, however, there's still overhead. there are currently no options to configure this, but this could be added very easily, including whether to keep the historic state at all, which should decrease memory footprint. |
configuration option will be very helpful. |
+1 on adding an option to configure this option - the memory/storage footprint is significant |
I think this might be related but I've noticed the tests in https://github.com/0xSplits/splits-liquid slow down significantly after a few runs & eventually just start intermittently failing |
+1 on adding this - this would be super impactful and significantly improve performance on long-running simulations. |
Can folks check if running tests with #3488 fixes it? |
@mattsse can u take a look here? |
@paco0x how can I reproduce this? |
I'm running a simulation script that replays thousands of historical txs on Uniswap V3 in a forked network. Sorry, the code cannot share here but I assume the issue is not related to any specified contract. All the APIs used in this script are:
With the transactions being executed in this forked network, the memory footprint of As aforementioned, I also tried to call |
Anvil is keeping all mined transaction in memory, so proposal is to add config option that will limit number of block with transaction in memory This is workaround Related to foundry-rs#3478
We're also seeing memory issues while using a local subgraph trying to index a large set of events. Eventually Anvil stops responding. |
Would like to see a repro please, hard to debug otherwise! Thanks and appreciate the help/understanding. Did you use the fix from #3836? |
I'm working with @0xalecks on this. Repro steps are here: https://gist.github.com/0xalecks/b42bc64302043b16cfe6e9464eadcb5f I tried the fix in #3836 but did not notice any improvement. Thanks. |
Got it - will investigate, ty for the repro. What paremeter did you set for |
I tried |
Any updates on this? We're on hold waiting to see if this is something that might be fixed in Anvil or if we have to switch to a completely different solution. 🙏 |
We'll take a pass this week - thanks! @mattsse PTAL, repro here Was hoping somebody would've given some more debug information by now vs assuming we'll do all the debugging end to end^^ |
@marshall-bean sorry for the wait. I tried to replicate this but the
does this also happen on master? could you perhaps please also try with the |
Yes is also happens on master, apologies. Please let me know if you have any further issues reproducing. I can try again with |
Yeah pls give it a shot @marshall-bean |
I failed to get it working on first try, start timed out... can try again in a bit |
We tested this out yesterday and found that |
great, so this seems to be an issue with the default limits for historic state that we keep in memory. I guess we can make this smarter and auto adjust best on some estimation |
I guess we could turn prune history and max transaction keeper on by default with some reasonable bounds? |
… (#3836) * Due our work with anvil we faced huge memory consumption for long tests Anvil is keeping all mined transaction in memory, so proposal is to add config option that will limit number of block with transaction in memory This is workaround Related to foundry-rs/foundry#3478 * make clippy happy
has this been turned on? I wonder if it could be the source of this error:
|
anvil
): memory / storage leak in long running test against Anvil
this should be solved now with #8412, please retest and reopen if still an issue. thank you |
Component
Anvil
Have you ensured that all of these are up to date?
What version of Foundry are you on?
No response
What command(s) is the bug in?
No response
Operating System
Linux
Describe the bug
Hey, I run a long test with 10K blocks on anvil.
After some time I saw that memory and and storage usage of anvil has increased drastically.
I found that anvil is keeping mined blocks at file system as json files, also after digging in code, I think that blocks also kept in memory.
Is it intentional? Can I limit in some way number of blocks that kept in memory or at file system ?
Can I configure where to keep those files?
Thanks
The text was updated successfully, but these errors were encountered: