leaningtech / webvm

Virtual Machine for the Web
https://webvm.io
Apache License 2.0
9.08k stars 1.43k forks source link

loading fs cache is very slow #12

Closed dominictarr closed 1 year ago

dominictarr commented 2 years ago

I ran the recommended python example and was surprised to see how much faster it ran the second time. then I say that there was node js examples, so I tried running node, and well, it's been trying to load in another tab while I've been writing this issue and it's still not there.

I opened the dev tools and on the network tab I saw it's doing a bunch of xhr's like https://disks.leaningtech.com/webvm_20220131.ext2?s=796655616&e=796786687 it seems to do them one at a time... (okay node has opened now) I can see this is part of the file system... each block is 128kb, which isn't big, but there is certainly a delay between each block.

To be useful this needs to be much faster. It seems to me that the high latency means a much larger block size (and thus fewer requests) would be much faster.

alexp-sssup commented 1 year ago

We have implemented a new disk backend based on CloudFlare workers that should significantly improve the performance on both cold and warm CDN nodes. It is deployed on https://webvm.io/

jaulz commented 1 year ago

@alexp-sssup that sounds cool, will it even be possible to use it without CloudFare?

alexp-sssup commented 1 year ago

There is already a different backend if you want to self-host the image, but this new backend is only intended for a CDN scenario and CloudFlare specific APIs.

jaulz commented 1 year ago

@alexp-sssup could you please point me to a resource where I can read about it (if there is any)? 😊

alexp-sssup commented 1 year ago

We have given some details about disk backends here: https://leaningtech.com/mini-webvm-your-linux-box-from-dockerfile-via-wasm/

Self-hosting disks is trivial, you can simply use any regular HTTP server and the bytes backend.

See the WebVM source for reference: https://github.com/leaningtech/webvm/blob/main/index.html#L324