Skip to content

Commit

Permalink
fix: fix perf bug in mox compile (#159)
Browse files Browse the repository at this point in the history
* fix compile perf bug

fix a perf bug in mox compile. `compile_` was returning the deployer,
which pickles it to the process's stdout. however, this is not necessary
as the result is not used.

on my machine, this brings warm compile of 36 contracts from 5s to 2.2s.

* fix signature

* fix regression -- inspect module uses compile_

add a wrapper for use by multiprocessing which discards the result.
  • Loading branch information
charles-cooper authored Nov 19, 2024
1 parent 37a4ecf commit e58cb35
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions moccasin/commands/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def compile_project(
with multiprocessing.Pool(n_cpus) as pool:
for contract_path in contracts_to_compile:
res = pool.apply_async(
compile_,
compile_noret,
(contract_path, build_folder),
dict(is_zksync=is_zksync, write_data=write_data),
)
Expand Down Expand Up @@ -150,7 +150,7 @@ def compile_(
compiler_args: dict | None = None,
is_zksync: bool = False,
write_data: bool = False,
) -> VyperDeployer | None:
) -> VyperDeployer | VVMDeployer:
logger.debug(f"Compiling contract {contract_path}")

# Getting the compiler Data
Expand Down Expand Up @@ -209,3 +209,8 @@ def compile_(
logger.debug(f"Done compiling {contract_name}")

return deployer

# discard the result of the compilation so that we don't need to pickle it
# between processes
def compile_noret(*args, **kwargs) -> None:
compile_(*args, **kwargs)

0 comments on commit e58cb35

Please sign in to comment.