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

Memory pool/reuse #732

Merged
merged 27 commits into from
May 31, 2024
Merged

Memory pool/reuse #732

merged 27 commits into from
May 31, 2024

Conversation

Dentosal
Copy link
Member

@Dentosal Dentosal commented May 8, 2024

Used by #732

Adds a method to reset memory to the original state.

Also adds a memory pool to allow reusing memory instances, and use that for all VM initializations.

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests

Before requesting review

  • I have reviewed the code myself

@Dentosal Dentosal self-assigned this May 8, 2024
@Dentosal Dentosal requested a review from a team May 8, 2024 01:42
@Dentosal Dentosal marked this pull request as ready for review May 8, 2024 01:42
@Dentosal Dentosal changed the title Add memory reset method Add memory pooling May 10, 2024
@Dentosal Dentosal changed the title Add memory pooling Memory pool/reuse May 10, 2024
fuel-vm/src/interpreter/executors/main.rs Outdated Show resolved Hide resolved
fuel-vm/src/interpreter/executors/main.rs Outdated Show resolved Hide resolved
fuel-vm/src/interpreter/executors/main.rs Outdated Show resolved Hide resolved
fuel-vm/src/interpreter/memory.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

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

We also need to add a new constructor to the Interpreter that accepts the memory as input and calls reset on it during initialization.

@Dentosal Dentosal marked this pull request as draft May 13, 2024 14:24
@Dentosal Dentosal marked this pull request as ready for review May 13, 2024 16:39
fuel-vm/src/pool.rs Outdated Show resolved Hide resolved
fuel-vm/src/checked_transaction/builder.rs Outdated Show resolved Hide resolved
fuel-vm/src/interpreter.rs Outdated Show resolved Hide resolved
fuel-vm/src/interpreter/alu/wideint.rs Show resolved Hide resolved
fuel-vm/src/interpreter/constructors.rs Outdated Show resolved Hide resolved
#[cfg(test)]
impl<Tx, Ecal> Interpreter<(), Tx, Ecal>
#[cfg(any(test, feature = "test-helpers"))]
impl<Tx, Ecal> Interpreter<MemoryFromPool, (), Tx, Ecal>
Copy link
Collaborator

Choose a reason for hiding this comment

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

All functions below can just be generic

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't make much sense, when Default already returns a concrete type.

fuel-vm/src/interpreter/debug.rs Outdated Show resolved Hide resolved
@@ -29,19 +30,21 @@ where
const INC_PC: bool = true;

/// ECAL opcode handler
fn ecal<S, Tx>(
vm: &mut Interpreter<S, Tx, Self>,
fn ecal<M, S, Tx>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I think M, S, and Tx should be generics of the EcalHandler. Otherwise, the implementer doesn't have control over the constraints for these generics. The M: AsRef<Memory> + AsMut<Memory> is an example. What is he needs some contains over the storage?

Copy link
Member Author

Choose a reason for hiding this comment

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

Leaving this as a follow-up. #734

fuel-vm/src/interpreter/executors/main.rs Outdated Show resolved Hide resolved
fuel-vm/src/interpreter/memory.rs Outdated Show resolved Hide resolved
@Dentosal Dentosal requested review from xgreenx and MitchTurner May 14, 2024 19:10
@Dentosal Dentosal added this pull request to the merge queue May 31, 2024
Merged via the queue into master with commit 6e8920b May 31, 2024
38 checks passed
@Dentosal Dentosal deleted the dento/memory-reset branch May 31, 2024 15:05
@xgreenx xgreenx mentioned this pull request Jun 3, 2024
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.

3 participants