Greetings folks.
As per yesterday’s post, I now have ruby running in a canister.
It has me thinking starting to think about how to best conceptualize a canister.
I’m still getting used to wasm runtimes, alongside the specifics of ICP.
As I currently understand it, a canister will:
a. boot an app
b. allow the app to write memory to its heap/stable structures
c. kill the app’s process if it didn’t exit itself within the instruction count limit
Setting aside IC for a moment, If I pack a ruby.wasm, and then run wasmtime run packed-app.wasm -e 'puts 1', it will take 8 to 10 seconds to return on my machine on the first pass. Then maybe 800ms on second pass:
time wasmtime run ../ruby_wasm_builder/packed-app.wasm -e 'puts 1'
1
real 0m0.368s
user 0m0.167s
sys 0m0.202s
which is about 4x larger than running native:
time ruby -e 'puts 1'
1
real 0m0.110s
user 0m0.068s
sys 0m0.030s
I don’t know where that difference comes from yet but wasmtime seems to have a ‘cold-boot’ and a ‘warm-boot’ time.
Now, when I look to my demo. I’m seeing maybe 2-4s delay before the frontend gets its response from the backend. I’m going to naively call this analogous to the ‘warm boot’ of a non-IC wasm run locally.
In my opening post, I was interested to learn about how the consensus mechanism limits the instruction to 40b per-request (in a request-response scenario).
I’ve now read the articles about the rust-cdk and stable structures. I haven’t tried yet but I suspect that I’ll able to pull rust-cdk into my buildsystem and drive it alongside wasi-sdk to produce future builds.
I also understand that the stable structures have lots of space available. The 10Mb limit almost reads like a bootstrapping step (to my interpreted language point of reference) if the memory and storage can persist between consensus cycles. What if I just load my app code into that stable structure?
In that case, I can perhaps limit the scope of my future builds to wiring the interpreter into all IC system specific calls, then on getting the interpreter’s warm-boot time down.
Even canister specific calls could perhaps just be a gem (package) of wrapped functions?
How does that mesh with what people have been doing for web-servers to date? I saw that the quickstarts show front-end frameworks. So are people even running webservers on the back end? or doing something more akin to direct db calls?
Cheers