-
Notifications
You must be signed in to change notification settings - Fork 443
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
Remove all #[inline.*]
s
#1666
Remove all #[inline.*]
s
#1666
Conversation
Let's check the contracts size change report. |
@agryaznov the waterfall isn't running anymore, so you're gonna have to check manually and update us on this |
addressed in #1667 |
@agryaznov since the waterfall (still) isn't working, can you provide us with manual sizes? |
It's been two years from the last attempt to do what this PR is intended to. I don't think we are in a rush with this and I don't think "manual sizes" is a right thing to do whatsoever. Let's hold on until waterfall is fixed, which seems to be a more urgent issue anyway. |
Getting the sizes manually is not that hard. If you take a look at what the waterfall is doing for size calculations it's basically running a single script in a loop (one for |
Waterfall is back #1667, merge master |
The point is not about how's that hard or not. It's about using representative reproducible benchmarks, to compare a taken effect in a sustainable way. Manual testing was taken to justify adding those attributes. Let's not make it a vicious practice. |
🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑These are the results when building the
Link to the run | Last update: Tue Oct 17 17:39:42 CEST 2023 |
So no changes in gas, but the contract sizes got bigger. |
Codecov Report
@@ Coverage Diff @@
## master #1666 +/- ##
===========================================
+ Coverage 52.93% 70.93% +17.99%
===========================================
Files 219 205 -14
Lines 6780 6409 -371
===========================================
+ Hits 3589 4546 +957
+ Misses 3191 1863 -1328
... and 150 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@cmichi I've tweaked optimization options a little, which resulted in size decrease for most of the example contracts. See the updated report above. We still get slightly enlarged sizes of the following contracts:
I have some ideas on how we could try to make them smaller, too. Will propose them in a follow-up PR if succeeded. |
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.
It looks like the sizes go down for most contracts and up for some. So it is more or less neutral with a tendency to positive. Which is enough to remove the attributes.
I rather have the optimizer make this decision using its global view of the code than follow gut feeling.
I will approve once you revert your profile changes to the examples.
cargo-contract's default |
I don't think we should customize here. We should just switch the default to Customizing here is brittle. Small changes can make |
I don't think it should be the same option for all the contracts. Contracts are different in their design, and different optimization options for them is fine. If we change a contract we can do this easy benchmarking to ensure which of the two options ( Also, some contract authors would optimize for size, others for speed. This is why llvm gives these options to them to decide. By setting non-default options for at least some of the contracts, we give ink! contracts developers an explicit example of such an optimization. |
I agree that we should teach contract authors that changing the
If we still decide to override we should only override |
Alright, the argument that these contracts are not examples anymore, they became the integration tests, never deployed anywhere except a single substrate-contracts-node during CI, is accepted. And the clearing the profile config to just have a single non-default option, is fine by me. So the questions left are:
|
This is just my opinion. @cmichi @ascjones should whey in here before we make a decision. |
I assume you mean we should only override those values which differ from the defaults. The behaviour is that the defaults are only used if not specified in So if you only specify |
@agryaznov Could you resolve the merge conflicts? We can merge right after that. |
@agryaznov resolve conflicts, merge |
Thanks! the CI job updated the results to the comment above. ( tl;dr: almost all contracts sizes increased with the change ); ) |
so this initial hypothesis proved to be wrong by made measurements, hence closing this PR |
This is a reincarnation of #1019 to close #1035 .
These attributes were placed there as a result of some particular test being ran just once, like e.g. in this PR, and probably in some others, all following the same approach. Although those tests could had shown somewhat improvement on contracts sizes, such approach to optimization is in-sustainable in its root.
Both
#[inline]
and#[inline(always)]
are just hints to the compiler, which inlines functions based on its internal heuristics. As said heuristics change over time, it makes no sense to code against what compiler does in a particular case on a particular run. Rather, we should code against what compiler is allowed to do in general.Given link-time optimization is turned on by default when building contracts, those attributes should not really affect the compilation result in general.
Therefore it's nothing really wrong with removing all
inline
s with: