Avatar for the FuelLabs user
FuelLabs
sway
BlogDocsChangelog

Performance History

Latest Results

Optimize type casting by using `__transmute` instead of `asm` blocks (#7675) ## Description This PR improves gas costs and bytecode sizes by consistently replacing `asm`-based conversions of _reference types_ in `std` with `__transmute`. Note that **copy-types are still converted using `asm` blocks**, because currently we didn't extend `__transmute` to handle copy-types without demoting transmuted values to stack and actually casting pointers. This gives a performance penalty when transmuting copy-types which we don't want to have. As expected, removing `asm` blocks unlocked existing IR performance optimizations and resulted in performance improvements given in the comment below. Note that we might think of temporarily forbidding using `__transmute` with copy-types until it is properly supported. But we have code in `ops.sw` where `__transmute` must be used to convert between copy-types, because the operator trait methods must be const-evaluable and if they use `asm` for conversion, they cannot be. Historically, making them const-evaluable was the reason for adding `__transmute` in the first place. Note that in the future, we plan to improve IR optimizations by letting them be aware of "safe `asm` blocks". Pure conversion blocks will be considered safe. That improvement would likely bring the same performance benefits as rolling out `__transmute`, but: - it will take some time before we get it implemented, - regardless, `__transmute` is the expected way to convert types and we should use it consistentlty across the codebase. Note that the PR changes snapshot files in the `sway-ir` tests. These changes are not related to this PR, but likely to the snapshots not being updated because of the `insta` checks being silent. For more info see https://github.com/FuelLabs/sway/pull/7666#pullrequestreview-4589675640. ## Checklist - [x] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
master
18 hours ago
Fix forc-fmt empty if-body + else collapsing onto one line (#7628) ## Description Fixes #7625 `forc-fmt` collapses empty if-body + else onto a single line: ```sway // Before (wrong): if __size_of::<T>() == 0 { } else if __is_reference_type::<T>() { // After (correct): if __size_of::<T>() == 0 { } else if __is_reference_type::<T>() { ``` **Root cause**: In `format_then_block`, when the then-block is empty and has an else clause, `block_unindent()` was called but no newline was written — so the closing `}` from `format_else_opt` ended up on the same line. **Fix**: Write a newline after the empty body when an else clause exists, and skip `block_unindent` since `close_curly_brace` in `format_else_opt` already handles unindentation. Guarded with `LineStyle::Inline` to avoid injecting newlines during width measurement probes. ## Checklist - [x] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Igor Rončević <ironcev@hotmail.com>
master
2 days ago
remove checl for local var immutability
xunilrj/fix-opt-passes-convergence
7 days ago
remove checl for local var immutability
xunilrj/fix-opt-passes-convergence
7 days ago
PR adjustments
xunilrj/fix-opt-passes-convergence
7 days ago

Latest Branches

CodSpeed Performance Gauge
0%
Removing verify-ir from the CLI#7672
7 days ago
7e7ce5e
xunilrj/removing-cli-verify
CodSpeed Performance Gauge
0%
fix modified in optimisation passes so they converge#7666
7 days ago
5946264
xunilrj/fix-opt-passes-convergence
CodSpeed Performance Gauge
-16%
10 days ago
d665a3a
ironcev/refactor-std-tests
© 2026 CodSpeed Technology
Home Terms Privacy Docs