-
Notifications
You must be signed in to change notification settings - Fork 125
Use -Clinker-plugin-lto flag during Wasm build
#358
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
Merged
ascjones
merged 2 commits into
use-ink:master
from
Supercolony-net:feature/reduce-size-flag
Nov 16, 2021
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the
-Cltowill override the release profile which we automatically append/merge to the contract'sCargo.toml. See https://github.com/paritytech/cargo-contract/blob/a8c8589798c05468b41e8125b6c5c3c1194178b6/src/workspace/profile.rs#L22.I think we might still need to pass
Clinker-plugin-ltodirectly as an argument, but AFAIU it seems dependent upon-Cltowhich is configurable from the[profile.release]The philosophy we have followed so far is that we should provide sensible defaults for these values, but also allow the user to override them, because the same hardcoded flags might now always produce the optimal contract size for all contracts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think if we will add it automatically here if lto is on?=)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clinker-plugin-ltois not a profile setting https://doc.rust-lang.org/cargo/reference/profiles.html.What effect does just having
Cltoon its own have on the size?Anyway if this flag is providing such big gains, and doesn't harm any of the other
Ltooptions then we can possibly hardcode it.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example that contract takes space:
Without
-Cltoand-Clinker-plugin-lto: Original wasm size: 100.5K, Optimized: 47.9KWith
-Clto: Original wasm size: 68.6K, Optimized: 31.9KWith
-Cltoand-Clinker-plugin-lto: Original wasm size: 67.2K, Optimized: 31.0KI tried it on contracts from that folder and it causes a positive effect for all of them(but all of them has a heavy logic, except
reentrancy. Forreentrancyit causes a low impact there).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did measurements for
reentrancy. Also, I removed explicit-Cltobecause it causes a compilation error if it is disabled or not aplieable. I tested compiler will use-Clinker-plugin-ltoif he can.flipper:
Original wasm size: 38.9K, Optimized: 12.5K
Original wasm size: 24.4K, Optimized: 4.5K
Original wasm size: 24.1K, Optimized: 4.2K
flip_on_me:
Original wasm size: 33.8K, Optimized: 10.2K
Original wasm size: 21.5K, Optimized: 2.6K
Original wasm size: 21.2K, Optimized: 2.3K