feat: memoize compiler verification per worker #196
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR speeds up the solc compile step of validation.
Previously, after preprocessing to build the solc input object, to compile we ran the
TASK_COMPILE_SOLIDITY_COMPILE
task. This has three subtasks:The build subtask checks if the compiler for the given version is downloaded (downloading it if it is not), then verifies the checksum of the file. The solc or solcjs tasks (the actual solc compilation) are then run depending on which compiler was downloaded.
The build task adds hundreds of millisecond to a validation run (dwarfing the actual solc compile time).
This PR pulls up the subtasks of
TASK_COMPILE_SOLIDITY_COMPILE
and memoizes the results ofTASK_COMPILE_SOLIDITY_GET_SOLC_BUILD
using a newcompilerMetadataCache
entry in theworkerState
of the worker process.The first build job in a worker for a particular solc version will take the cost of the compiler verification, but all subsequent build jobs for that worker will avoid it, speeding up validation.