foundry
foundry copied to clipboard
perf: improve pc/ic mapping stuff
Motivation
After enabling fuzz tests in coverage (no data is used yet) coverage went from taking about 2 seconds for solmate to 27 seconds. The hottest piece of code seems to be the coverage collector itself that does some very expensive computations (translating program counters to instruction counters and then recording them) on every call.
Solution
Instead of doing the PC -> IC translation in the inspector, we can do it once before or after we collect hit data. The hit data is then just a mapping of PC -> hits. This took the time back down to 2 seconds.
For coverage I opted to just move from using instruction counters in the anchors to program counters, so we use an IC -> PC map (since source maps are based on instruction counters, we need to translate from instruction counters to program counters in some cases).
I'll look into doing the same for the debugger, because it uses the same translation mechanism
is there something blocking us here?
no, will get it over the line today, just want to do the same for debugging and have been focusing on the solc AST PR