EVM JSON outputs are generated even when not requested #15615
Labels
bug 🐛
low effort
There is not much implementation work to be done. The task is very easy or tiny.
medium impact
Default level of impact
performance 🐎
Description
Certain
evm.*.*
output is generated in memory even when not requested throughoutputSelection
. This wastes resources on computing values that are discarded immediately after.In Foundry, we updated the
outputSelection
to only include specific fields ofevm.bytecode.*
as we don't make use of all of them, which was a substantial win in compilation times: foundry-rs/compilers#231. The biggest contributor to this was excludinggeneratedSources
from the JSON, as these can become very large.The default output selection is now:
However, I profiled the compiler and noticed that it was still calling
generatedSources
.Here's a profile generated from
forge build --use <solc 0.8.29-develop.2024.10.22+commit.9c4995a9.mod.Linux.g++>
on superform-xyz/superform-core @ 7b69077 (this is an older build of solc but it should still apply): https://share.firefox.dev/3BaYnLD, using samplyYou can see that there is a 4% frame of
CompilerStack::generatedSources
.I believe this happens in
StandardCompiler
. It is generated and passed eagerly tocollectEVMObject
when anyevm.bytecode*
output is requestedsolidity/libsolidity/interface/StandardCompiler.cpp
Lines 1509 to 1522 in 8da621c
but then discarded if the individual
evm.bytecode.generatedSources
is not requestedsolidity/libsolidity/interface/StandardCompiler.cpp
Lines 399 to 400 in 8da621c
The same applies to other fields, like
sourceMap
.Environment
Steps to Reproduce
Compile anything with
evm.bytecode.object
output selection, see above.The text was updated successfully, but these errors were encountered: