Skip to content

Conversation

@xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Sep 26, 2025

Description

This PR introduces the concept of "memcopy" for encoding/decoding.

Whena type does not have a pointer, in a lot of cases, its decoding can simply be a memcopy. Taking advantage of this fact, we now check these cases and generate much simpler code.

Checklist

  • 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).
  • 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.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 27, 2025

CodSpeed Performance Report

Merging #7419 will not alter performance

Comparing xunilrj/encoding-optimizations (6fe6bea) with master (8e44f53)

Summary

✅ 25 untouched

@xunilrj xunilrj force-pushed the xunilrj/encoding-optimizations branch from 9e46a4e to ca4d8a3 Compare October 3, 2025 14:18
@umitsahintde
Copy link

good job

xunilrj added a commit that referenced this pull request Oct 16, 2025
## Description

This PR is a prequel for #7419.
It will set the baseline, which future PRs need to improve.

Apart from that it also:
1 - Fix a problem with `SubtsType` for `TyConstantDecl`;
2 - Introduce a new way to write snapshot tests. Now the test source
code can have "blocks"

```
    /* START BOOL */
    fn in_bool(v: bool) -> bool;
    /* END BOOL */
```

These blocks can be manipulated from inside the `snapshot.toml`. In this
case, the `toml` is:

```
cmds = [
    "forc test --path {root} --release --experimental const_generics",
    { repeat = "for-each-block", cmds = [
        "forc test --path {root} --release --experimental const_generics"
    ] }
]
```

Which repeats the inner `forc test` for each block, removing all others.
That allows me to check the cost of the contract method selection
algorithm for each contract method.

For example, `cost_of_in_array_64` with all other contract methods costs
`60382`, but alone it only costs `58218`, which means that around 2000
was "wasted" in the contract method selection.

## Checklist

- [x] I have linked to any relevant issues.
- [x] 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.
- [ ] 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants