foundry icon indicating copy to clipboard operation
foundry copied to clipboard

perf: improve pc/ic mapping stuff

Open onbjerg opened this issue 3 years ago • 2 comments

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

onbjerg avatar Aug 04 '22 19:08 onbjerg

is there something blocking us here?

gakonst avatar Aug 09 '22 17:08 gakonst

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

onbjerg avatar Aug 09 '22 19:08 onbjerg