ZenVoich / mops

Package manager for the Motoko programming language
https://mops.one
MIT License
35 stars 3 forks source link

perf: dfx build slow due to moc-wrapper #222

Closed crusso closed 2 months ago

crusso commented 3 months ago

I've noticed that utilizing the DFX_MOC_PATH=moc-wrapper indirection to select a particular moc binary, though convenient, can drastically slow down builds using dfx.

The problem is that dfx actually invokes moc repeatedly to determine the dependencies of a motoko project, not just once. On my machine, calling moc indirectly through moc-wrapper is about 50x slower than calling a particular moc binary.

See https://github.com/dfinity/sdk/pull/3699 for an example.

Once we've determined which binary to use, the overhead can be avoided by re-defining DFX_MOC_PATH accordingly so there is a manual workaround, but it causes friction.

@ZenVoich can you think of any way to fix this? Is there a clean and safe way to cache the result?

ZenVoich commented 2 months ago

Optimized moc-wrapper to cache moc path to a file. So it will not run nodejs every time.

For mops canister, speed up is ~30%, 25s -> 18s

ZenVoich commented 2 months ago

Released in 0.44.0