Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: opt 3 no lto #66

Closed
wants to merge 1 commit into from
Closed

rust: opt 3 no lto #66

wants to merge 1 commit into from

Conversation

chenyan-dfinity
Copy link
Contributor

No description provided.

@chenyan-dfinity chenyan-dfinity added the build_base Build base instead of fetching from gh-pages. Note that the build tool runs in the same version label Jul 20, 2023
@github-actions
Copy link

Note
Diffing the performance result against the published result from main branch.
Unchanged benchmarks are omitted.

Basic DAO

binary_size init transfer_token submit_proposal vote_proposal
Motoko 225_805 37_493 ($\textcolor{red}{0.06\%}$) 16_270 ($\textcolor{red}{0.26\%}$) 12_700 ($\textcolor{green}{-0.02\%}$) 14_155 ($\textcolor{green}{-0.01\%}$)
Rust 778_985 498_361 ($\textcolor{green}{-0.01\%}$) 93_215 114_281 124_684

DIP721 NFT

Note
Same as main branch, skipping.

Heartbeat

binary_size heartbeat
Motoko 118_909 3_751
Rust 29_905 916 ($\textcolor{red}{67.46\%}$)

Timer

Note
Same as main branch, skipping.

@github-actions
Copy link

Note
The flamegraph link only works after you merge.
Unchanged benchmarks are omitted.

Sample Dapps

Measure the performance of some typical dapps:

  • Basic DAO,
    with heartbeat disabled to make profiling easier. We have a separate benchmark to measure heartbeat performance.
  • DIP721 NFT

Note

  • The cost difference is mainly due to the Candid serialization cost.
  • Motoko statically compiles/specializes the serialization code for each method, whereas in Rust, we use serde to dynamically deserialize data based on data on the wire.
  • We could improve the performance on the Rust side by using parser combinators. But it is a challenge to maintain the ergonomics provided by serde.
  • For real-world applications, we tend to send small data for each endpoint, which makes the Candid overhead in Rust tolerable.

Basic DAO

binary_size init transfer_token submit_proposal vote_proposal
Motoko 225_805 37_493 16_270 12_700 14_155
Rust 778_985 498_361 93_215 114_281 124_684

DIP721 NFT

binary_size init mint_token transfer_token
Motoko 183_882 12_181 22_319 4_710
Rust 855_729 134_110 345_058 84_494

Heartbeat / Timer

Measure the cost of empty heartbeat and timer job.

  • setTimer measures both the setTimer(0) method and the execution of empty job.
  • It is not easy to reliably capture the above events in one flamegraph, as the implementation detail
    of the replica can affect how we measure this. Typically, a correct flamegraph contains both setTimer and canister_global_timer function. If it's not there, we may need to adjust the script.

Heartbeat

binary_size heartbeat
Motoko 118_909 3_751
Rust 29_905 916

Timer

binary_size setTimer cancelTimer
Motoko 125_168 15_208 1_679
Rust 498_182 50_977 9_766

@chenyan-dfinity chenyan-dfinity deleted the opt-3-no-lto branch July 20, 2023 18:17
@chenyan-dfinity chenyan-dfinity mentioned this pull request Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build_base Build base instead of fetching from gh-pages. Note that the build tool runs in the same version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant