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

feat(interpreter): add more helper methods to memory #794

Merged
merged 4 commits into from
Oct 16, 2023

Conversation

DaniPopes
Copy link
Collaborator

These would be useful in Foundry.
Second commit reduces usage of inline always since it's almost always unnecessary, and sometimes can hinder performance when normal inline hint is enough.
In release mode in our case performance is the same.


/// Sets the given 32-byte `value` to the memory region at the given `offset`.
///
/// Panics on out of bounds.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Panics on out of bounds.
/// # Panics
///
/// Panics on out of bounds.

/// Sets the `byte` at the given `index`.
///
/// Panics when `index` is out of bounds.
#[inline(always)]
/// Panics on out of bounds.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Panics on out of bounds.
/// # Panics
///
/// Panics on out of bounds.


/// Returns a U256 of the memory region at the given offset.
///
/// Panics on out of bounds.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Panics on out of bounds.
/// # Panics
///
/// Panics on out of bounds.


/// Returns a 32-byte slice of the memory region at the given offset.
///
/// Panics on out of bounds.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Panics on out of bounds.
/// # Panics
///
/// Panics on out of bounds.

}
}

/// Returns the byte at the given offset.
///
/// Panics on out of bounds.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Panics on out of bounds.
/// # Panics
///
/// Panics on out of bounds.

@rakita
Copy link
Member

rakita commented Oct 12, 2023

Jsut to talk about this a little:
General topic of inlining: https://matklad.github.io/2021/07/09/inline-in-rust.html

https://indico.cern.ch/event/386232/sessions/159923/attachments/771039/1057534/always_inline_performance.pdf
This slide from 2015 says that:
for Intel compiler inline is faster than others modifiers (or combination), On the worst case, inline is similar to always_inline
For GCC always_inline with 10M is usually faster than other modifiers, in worst case, always_inline is similar to inline

We do have LTO set to true.

It seems that the thing with inlining is to always measure

@rakita rakita merged commit 2f78eb9 into bluealloy:main Oct 16, 2023
8 checks passed
@DaniPopes DaniPopes deleted the memory-methods branch October 16, 2023 08:45
@github-actions github-actions bot mentioned this pull request Jan 12, 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.

None yet

2 participants