fuel-vm icon indicating copy to clipboard operation
fuel-vm copied to clipboard

Narrow integer load/store operations

Open Dentosal opened this issue 9 months ago • 1 comments

Spec PR: https://github.com/FuelLabs/fuel-specs/pull/628

Adds LQW LHW SQW SHW instructions to store and load quarter and half words efficiently. They follow the same conventions as their pre-existiing counterparts LB LW SB SW. The new instructions have same cost as their full-word counterparts.

Checklist

  • [x] Breaking changes are clearly marked as such in the PR description and changelog: None!
  • [x] New behavior is reflected in tests
  • [ ] If performance characteristic of an instruction change, update gas costs as well or make a follow-up PR for that: using gas costs of existing instructions as a baseline
  • [x] The specification matches the implemented behavior: https://github.com/FuelLabs/fuel-specs/pull/628

Before requesting review

  • [x] I have reviewed the code myself
  • [ ] I have created follow-up issues caused by this PR and linked them here

Dentosal avatar Mar 06 '25 03:03 Dentosal

@Dentosal Could you post benchmark results please? Just to show the impact of the change

This isn't really done for performance or code size reasons, but to help the compiler team with implementing the trickier details of stdlib implementation. I have a modified sway compiler in a way that shows minimum impact, but we can get way more out of these if we do advanced packing of the data section as well. (i.e. substring search, and ordering it in a way that produces the best substrings). Also this should make some optimizations with store ops possible, but those haven't been explored yet. I've benchmarked with the minimum impact version here:

The benchmark results for mira-v1-core (release build):

latest sway 8e162c966 after changes reduction
89.384 KB 88.764 KB 0.7%

Dentosal avatar Apr 07 '25 06:04 Dentosal

From my side the only blocker is adding proper support for the WASM constructors of these new instructions.

Voxelot avatar May 12 '25 21:05 Voxelot