-
Notifications
You must be signed in to change notification settings - Fork 0
Stop using stdio #99
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
base: jc.singleton-take2
Are you sure you want to change the base?
Stop using stdio #99
Conversation
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.
This is looking really good!
provider/src/lib.rs
Outdated
impl Default for Context { | ||
fn default() -> Self { | ||
Self { | ||
bump_allocator: Bump::new(), | ||
input_bytes: Vec::new(), | ||
output_bytes: ByteBuf::new(), | ||
logs: Vec::with_capacity(1024), |
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.
Given that we have now landed in explicit initialize
/ finalize
function invocations, I wonder if we should make this configurable from the host?
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 we briefly discussed that earlier on, maybe?
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 can pass it as an additional parameter in initialize. But also, it's a vector so it'll grow beyond the initial capacity if it needs to. But using the default capacity definitely hurts performance.
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.
Actually I guess another tradeoff is if the initial capacity changes, then the fuel consumption for a Function that performs logging may change as well. If we reduce the initial capacity, then a Function that performs enough logging to exceed the new capacity that would not have exceeded the old capacity would see an increase in fuel consumption. And if the initial capacity were increased, then a Function that performed enough logging to exceed the old capacity but not enough to exceed the new capacity would see a decrease in fuel consumption.
Built on top of removing context pointer and using singleton context.
Replace stdio with initialization and finalization functions relying on reading from and writing to in-memory buffers from the host instead of using WASI hostcalls. This introduces a ~27% reduction in fuel (14,828 to 10,830) in one of the benchmark cases when excluding the initialization and finalization invocations from the fuel measurements compared to the numbers when introducing the singleton context. The reduction in fuel compared to main for that benchmark test is ~32% (15,880 to 10,830).