Skip to content
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

Use DependentCost for aloc opcode #1934

Merged
merged 39 commits into from
Jun 6, 2024
Merged

Use DependentCost for aloc opcode #1934

merged 39 commits into from
Jun 6, 2024

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Jun 4, 2024

PR upgrades the fuel-vm to 0.52.0. A new VM changes aloc opcode to be DependentCost. It requires updated benchmarks.

The PR also updates default gas costs according to a new Vultr instance we use to do benchmarks. It works faster than the previous one, so all opcodes became cheaper.

The vm_initialziation became much cheaper and now has reasonable values. The bloc opcode became expensive and depended on a number of allocated bytes.

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog

Before requesting review

  • I have reviewed the code myself

After merging, notify other teams

  • Both SDKs

@xgreenx xgreenx self-assigned this Jun 4, 2024
@xgreenx xgreenx changed the title Feature/benchmarks alloc Use DependentCost for aloc opcode Jun 4, 2024
Base automatically changed from dento/reuse-vm-memory to master June 4, 2024 18:45
@xgreenx xgreenx requested a review from a team June 5, 2024 12:07
@xgreenx xgreenx marked this pull request as ready for review June 5, 2024 12:07
@@ -324,10 +324,9 @@ impl TryFrom<GasCosts> for fuel_core_types::fuel_tx::GasCosts {
fn try_from(value: GasCosts) -> Result<Self, Self::Error> {
match value.version {
GasCostsVersion::V1 => {
Copy link
Member

@Voxelot Voxelot Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is GasCostsVersion still V1 but GasCostsValues is now V2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GraphQL version doesn't need to match the Rust version of the type. It was done to maintain backward compatibility. Because SDKs will throw an error if the version is unknown.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it get confusing if the versions start diverging a lot over time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it will diverging a lot, we just can jump straight to the highest=) I was done for backward compatibility until SDKs will handle it gracefully.

@@ -82,7 +82,6 @@ query {
version
add
addi
aloc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this break older SDK versions loading the gas costs for predicate estimation?

@@ -338,7 +338,7 @@ impl GasCosts {
}

async fn aloc(&self) -> U64 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disregard my earlier comment, it looks like this will retain backwards compatibility

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the only problem is that if Rust SDK is old and connected to fuel-core 0.27.0, the predicate estimation can be incorrect if it uses an alco opcode. But it should be addressed on Rust SDK side: FuelLabs/fuels-rs#1409

Comment on lines +103 to +104
#[allow(clippy::unit_arg)]
black_box(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this black_box actually do anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing black_box improves speed
image

@xgreenx xgreenx requested review from Voxelot and Dentosal June 6, 2024 08:33
@@ -81,7 +81,7 @@ fuel-core-wasm-executor = { version = "0.27.0", path = "./crates/services/upgrad
fuel-core-xtask = { version = "0.0.0", path = "./xtask" }

# Fuel dependencies
fuel-vm-private = { version = "0.51.0", package = "fuel-vm", default-features = false }
fuel-vm-private = { version = "0.52.0", package = "fuel-vm", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog says your updating to 0.51.0, not 0.52.0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[#1888](https://github.com/FuelLabs/fuel-core/pull/1888): Upgraded `fuel-vm` to `0.51.0`. See [release](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.51.0) for more information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog related for 0.51.0 is from another PR, I just grouped everything together=)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we are being inconsistent about when we note these things, but I don't know that it matters

@@ -324,10 +324,9 @@ impl TryFrom<GasCosts> for fuel_core_types::fuel_tx::GasCosts {
fn try_from(value: GasCosts) -> Result<Self, Self::Error> {
match value.version {
GasCostsVersion::V1 => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it get confusing if the versions start diverging a lot over time?

@xgreenx xgreenx requested a review from MitchTurner June 6, 2024 22:17
@@ -81,7 +81,7 @@ fuel-core-wasm-executor = { version = "0.27.0", path = "./crates/services/upgrad
fuel-core-xtask = { version = "0.0.0", path = "./xtask" }

# Fuel dependencies
fuel-vm-private = { version = "0.51.0", package = "fuel-vm", default-features = false }
fuel-vm-private = { version = "0.52.0", package = "fuel-vm", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we are being inconsistent about when we note these things, but I don't know that it matters

@xgreenx xgreenx enabled auto-merge (squash) June 6, 2024 22:29
@xgreenx xgreenx merged commit 4986d4d into master Jun 6, 2024
30 checks passed
@xgreenx xgreenx deleted the feature/benchmarks-alloc branch June 6, 2024 22:36
@xgreenx xgreenx mentioned this pull request Jun 6, 2024
xgreenx added a commit that referenced this pull request Jun 7, 2024
## Version v0.28.0

### Changed
- [#1934](#1934): Updated
benchmark for the `aloc` opcode to be `DependentCost`. Updated
`vm_initialization` benchmark to exclude growing of memory(It is handled
by VM reuse).
- [#1916](#1916): Speed up
synchronisation of the blocks for the `fuel-core-sync` service.
- [#1888](#1888):
optimization: Reuse VM memory across executions.

#### Breaking

- [#1934](#1934): Changed
`GasCosts` endpoint to return `DependentCost` for the `aloc` opcode via
`alocDependentCost`.
- [#1934](#1934): Updated
default gas costs for the local testnet configuration. All opcodes
became cheaper.
- [#1924](#1924):
`dry_run_opt` has new `gas_price: Option<u64>` argument
- [#1888](#1888): Upgraded
`fuel-vm` to `0.51.0`. See
[release](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.51.0) for
more information.

### Added
- [#1939](#1939): Added API
functions to open a RocksDB in different modes.
- [#1929](#1929): Added
support of customization of the state transition version in the
`ChainConfig`.

### Removed
- [#1913](#1913): Removed dead
code from the project.

### Fixed
- [#1921](#1921): Fixed
unstable `gossipsub_broadcast_tx_with_accept` test.
- [#1915](#1915): Fixed
reconnection issue in the dev cluster with AWS cluster.
- [#1914](#1914): Fixed
halting of the node during synchronization in PoA service.

## What's Changed
* Removed dead code by @xgreenx in
#1913
* Added backward and forward compatibility integration tests for
forkless upgrades by @xgreenx in
#1895
* Fixed halting of the node in rare conditions by @xgreenx in
#1914
* Weekly `cargo update` by @github-actions in
#1928
* Fixed logging of the WASM executor by @xgreenx in
#1930
* Added support of customization of the state transition version in the
`ChainConfig` by @xgreenx in
#1929
* Document wasm toolchain installation, add rust-toolchain.toml by
@Dentosal in #1932
* Add optional `gas_price` argument to `dry_run_opt` by @hal3e in
#1924
* Reuse VM memory across executions by @Dentosal in
#1888
* Fixed reconnection issue in the dev cluster with AWS cluster by
@xgreenx in #1915
* Speeds up synchronisation of the blocks for the `fuel-core-sync`
service by @xgreenx in #1916
* Fixed unstable `gossipsub_broadcast_tx_with_accept` test by @xgreenx
in #1921
* Added API functions to open a RocksDB in different modes by @xgreenx
in #1939
* Use `DependentCost` for `aloc` opcode by @xgreenx in
#1934

## New Contributors
* @hal3e made their first contribution in
#1924

**Full Changelog**:
v0.27.0...v0.28.0
GoldenPath1109 added a commit to GoldenPath1109/fuel-core that referenced this pull request Sep 7, 2024
## Version v0.28.0

### Changed
- [#1934](FuelLabs/fuel-core#1934): Updated
benchmark for the `aloc` opcode to be `DependentCost`. Updated
`vm_initialization` benchmark to exclude growing of memory(It is handled
by VM reuse).
- [#1916](FuelLabs/fuel-core#1916): Speed up
synchronisation of the blocks for the `fuel-core-sync` service.
- [#1888](FuelLabs/fuel-core#1888):
optimization: Reuse VM memory across executions.

#### Breaking

- [#1934](FuelLabs/fuel-core#1934): Changed
`GasCosts` endpoint to return `DependentCost` for the `aloc` opcode via
`alocDependentCost`.
- [#1934](FuelLabs/fuel-core#1934): Updated
default gas costs for the local testnet configuration. All opcodes
became cheaper.
- [#1924](FuelLabs/fuel-core#1924):
`dry_run_opt` has new `gas_price: Option<u64>` argument
- [#1888](FuelLabs/fuel-core#1888): Upgraded
`fuel-vm` to `0.51.0`. See
[release](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.51.0) for
more information.

### Added
- [#1939](FuelLabs/fuel-core#1939): Added API
functions to open a RocksDB in different modes.
- [#1929](FuelLabs/fuel-core#1929): Added
support of customization of the state transition version in the
`ChainConfig`.

### Removed
- [#1913](FuelLabs/fuel-core#1913): Removed dead
code from the project.

### Fixed
- [#1921](FuelLabs/fuel-core#1921): Fixed
unstable `gossipsub_broadcast_tx_with_accept` test.
- [#1915](FuelLabs/fuel-core#1915): Fixed
reconnection issue in the dev cluster with AWS cluster.
- [#1914](FuelLabs/fuel-core#1914): Fixed
halting of the node during synchronization in PoA service.

## What's Changed
* Removed dead code by @xgreenx in
FuelLabs/fuel-core#1913
* Added backward and forward compatibility integration tests for
forkless upgrades by @xgreenx in
FuelLabs/fuel-core#1895
* Fixed halting of the node in rare conditions by @xgreenx in
FuelLabs/fuel-core#1914
* Weekly `cargo update` by @github-actions in
FuelLabs/fuel-core#1928
* Fixed logging of the WASM executor by @xgreenx in
FuelLabs/fuel-core#1930
* Added support of customization of the state transition version in the
`ChainConfig` by @xgreenx in
FuelLabs/fuel-core#1929
* Document wasm toolchain installation, add rust-toolchain.toml by
@Dentosal in FuelLabs/fuel-core#1932
* Add optional `gas_price` argument to `dry_run_opt` by @hal3e in
FuelLabs/fuel-core#1924
* Reuse VM memory across executions by @Dentosal in
FuelLabs/fuel-core#1888
* Fixed reconnection issue in the dev cluster with AWS cluster by
@xgreenx in FuelLabs/fuel-core#1915
* Speeds up synchronisation of the blocks for the `fuel-core-sync`
service by @xgreenx in FuelLabs/fuel-core#1916
* Fixed unstable `gossipsub_broadcast_tx_with_accept` test by @xgreenx
in FuelLabs/fuel-core#1921
* Added API functions to open a RocksDB in different modes by @xgreenx
in FuelLabs/fuel-core#1939
* Use `DependentCost` for `aloc` opcode by @xgreenx in
FuelLabs/fuel-core#1934

## New Contributors
* @hal3e made their first contribution in
FuelLabs/fuel-core#1924

**Full Changelog**:
FuelLabs/fuel-core@v0.27.0...v0.28.0
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.

4 participants