-
Notifications
You must be signed in to change notification settings - Fork 824
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: Implement MemoryUsage
for Instance
#2201
Conversation
lib/api/src/externals/function.rs
Outdated
pub struct WasmFunctionDefinition { | ||
// Address of the trampoline to do the call. | ||
#[memoryusage(ignore)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider #[loupe(ignore)]
or #[loupe(skip)]
. I think it's more common to use the crate name as a the unique first element in the attribute than the name of the trait. For example serde, structopt, WasmerEnv
.
Serde even does #[serde(skip_serializing)]
and #[serde(skip_deserializing)]
to disambiguate the two
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Let's move to #[loupe(skip)]
.
impl<K, V> MemoryUsage for SecondaryMap<K, V> | ||
where | ||
K: EntityRef, | ||
V: Clone + MemoryUsage, | ||
{ | ||
fn size_of_val(&self, tracker: &mut dyn MemoryUsageTracker) -> usize { | ||
mem::size_of_val(self) | ||
+ self | ||
.elems | ||
.iter() | ||
.map(|value| value.size_of_val(tracker) - mem::size_of_val(value)) | ||
.sum::<usize>() | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you probably also need to do self.default.size_of_val(tracker)
, but that's a small nit pick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
6a8fa5d
to
64c1f08
Compare
MemoryUsage
for Instance
MemoryUsage
for Instance
64c1f08
to
d801eb4
Compare
`MemoryUsage` is implemented for `[T; N]` only on rustc nightly. Wasmer uses the stable channel of rustc. Thus, we re-implement `MemoryUsage` for `V128` by using `V128.as_slice()`.
bors r+ |
2201: feat: Implement `MemoryUsage` for `Instance` r=Hywan a=Hywan # Description This patch implements `loupe::MemoryUsage` for `wasmer::Instance`. ~~This PR includes #2200. To review unique patches: https://github.com/Hywan/wasmer/compare/feat-memory-usage-module...feat-memory-usage-instance?expand=1~~ # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Ivan Enderlin <[email protected]>
Build failed: |
bors r+ |
Description
This patch implements
loupe::MemoryUsage
forwasmer::Instance
.This PR includes #2200. To review unique patches: https://github.com/Hywan/wasmer/compare/feat-memory-usage-module...feat-memory-usage-instance?expand=1Review