final_bawse•

I'm interested in using rust on cloudflare workers, but I'd also like to access their KV store. I couldn't find a way to access a KV store namespace from webassembly. Is this possible yet?

6
steveklabnik1rust•

Hi! I'm actually the PM of Workers KV.

TL;DR: yes, but you have to do the binding yourself. Here's an example: https://github.com/jRiest/the-best-goats/blob/master/src/lib.rs#L48-L60

("Ns" is short for "namespace")

7
final_bawse•

Nice! Thanks for the example. I did not know about the static method attribute in wasm bindgen. It was a few weeks ago, but I think I was just trying get and put as regular methods.

2
steveklabnik1rust•

Yeah, I actually wrote it that way first myself, but then I saw that example above, which was written by one of my co-workers. I like it better.

1
kodemizer•

I was wondering if CloudFlare might ever support workers running pure WASM outside of V8?

Workers are awesome, but I found them to be a bit slower than just running the same code natively on a container in AWS or GoogleCloud. I suspect this slowness might be because bootstrapping all of V8 just to run WASM is probably doing a lot of work that doesn't need to be done.

So is there any chance that workers might get support for running WASM modules directly (perhaps via cranelift) ?

1
Matthias247•

Afaik the whole reason for them moving to V8 workers and isolates was that they can multiplex workers of lots of customers in one VM, compared to having to spin up multiple VMs or containers. Therefore the bootstrapping reason you mentioned should not apply

2
steveklabnik1rust•

Correct. Wasm is expected to have *some* slowdown over native, so if u/kodemizer is experiencing a slowdown, I would attribute it to that first. V8 is *not* started up on every single request.

2
mattlock1984•

Fantastic post! Great overview and drill down onto the tooling 👏

Have you tried the Actix 2.0 with async / await yet?

4
snoyberg•

Thanks for the kind words!

I did some quick experimentation with Actix 2.0 (I think it was alpha2), but moved over to Hyper instead. I think some of my coworkers were going down the Actix testing rabbit hole while I was checking out Hyper 0.13. I don't have much to report unfortunately, sorry.

3
mattlock1984•

Just curious I'm still on actix 1 for a project. It's been running stable for months.

1