Skip to content

Comments

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

Merged
rakita merged 4 commits intobluealloy:mainfrom
DaniPopes:memory-methods
Oct 16, 2023
Merged

feat(interpreter): add more helper methods to memory#794
rakita merged 4 commits intobluealloy:mainfrom
DaniPopes:memory-methods

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.

///
/// 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
@DaniPopes DaniPopes deleted the memory-methods branch October 16, 2023 08:45
@github-actions github-actions bot mentioned this pull request Jan 12, 2024
This was referenced Mar 10, 2025
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