dfinity / dfinity/sdk

`dfx build` is much slower than direct usage of `moc`

Open
#3,702 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Rust
Stars
204
Forks
98
PR merge metrics
No merged PRs in 30d

Description

First raised at https://forum.dfinity.org/t/why-is-dfx-build-much-slower-than-direct-usage-of-moc/29513

$ time moc --idl --stable-types `mops sources` -o ~/t/test.wasm stress-test/stresser.mo
...
|real|0m33.963s|
|---|---|
|user|0m33.733s|
|sys|0m0.367s|

but

$ time dfx build stresser
...
|real|0m51.280s|
|---|---|
|user|0m52.176s|
|sys|0m2.641s|

stresser canister has no dependencies.

So dfx build is nearly 2 times slower than plain moc invocation. Why? (I suspect that it builds also a wallet canister and is slow because of this.)

This needs to be fixed: dfx build should be faster (or provide flags to make it fast).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported moc and dfx build stresser timings, using mops sources and the dependency-free stresser canister described in the issue. Trace what dfx build does beyond the direct moc invocation, then verify that the unnecessary overhead is removed or that an equivalent fast-build option works.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, cli, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.