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

wip on metering host fns #100

Merged
merged 8 commits into from
Nov 12, 2023
Merged

wip on metering host fns #100

merged 8 commits into from
Nov 12, 2023

Conversation

thedavidmeister
Copy link
Contributor

No description provided.

self.wasmer_metering_remaining_points
.as_ref()
.ok_or(wasm_error!(WasmErrorInner::Memory))?
.set(store_mut, 0i32.into())
Copy link
Member

Choose a reason for hiding this comment

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

How do these points get returned to the pool? It seems like not keeping part of the capacity requested to be claimed would mean that returning capacity on completion could get out of sync?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like that's not the idea. You allocate a certain amount of capacity and when it's gone it's gone until something calls set to top it back up?

I still wonder if accurately tracking the value to account for overrun and making the 'set' an 'increment by' makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ThetaSinner well changing the middleware from decreasing points to increasing would mean rewriting the middleware from the ground up

we're using the default setup from wasmer, and what i'm doing here is exposing it so that it can be accessed by host functions as well as the default wasm op counter

Copy link
Member

@ThetaSinner ThetaSinner Nov 8, 2023

Choose a reason for hiding this comment

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

I don't mean dropping the increasing part, the increasing part is fine. I'm looking at set_remaining_points and wondering if that should be a paired up increment rather than a set?

If this is just exposing something wasmer already does then fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ThetaSinner it's a direct port of https://github.com/wasmerio/wasmer/blob/master/lib/middlewares/src/metering.rs#L335 but not requiring the instance itself to be in the environment, all we need is the global

Copy link
Member

Choose a reason for hiding this comment

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

Understood thanks!

.try_into()
.unwrap();

assert!(before_decrease - after_decrease == dec_by);
Copy link
Member

Choose a reason for hiding this comment

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

Minor, optional:

assert_eq! here?

Then separate assertions on the next line so it's clear what failed if something goes wrong?

crates/host/src/env.rs Outdated Show resolved Hide resolved
crates/host/src/env.rs Show resolved Hide resolved
@thedavidmeister thedavidmeister merged commit 94f6853 into develop Nov 12, 2023
5 checks passed
@jost-s jost-s deleted the 2023-10-24-metering branch April 21, 2024 12:50
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