-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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] WebAssembly support #5878
base: master
Are you sure you want to change the base?
Conversation
Well, 39MB is super huge. for Binary WASM of Go-IPFS. Is there any alternative to improve upon decreasing the size. |
There are some ways to compress the code ~10x, I'm not sure how portable to wasm though |
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
bafa793
to
81ece3b
Compare
@magik6k this is really awesome. Do you intend to work on it more? or maybe try to get it merged in some way? |
I currently have a rather long list of things to do, but I'd like to get this at least to the stage where we could see how well it works/could work (say, by comparing vs js-ipfs) |
I managed to get the bundle down to 27mb by removing some of the larger dependencies we don't use here, like quic and btcec, and a bunch of other things. There's a lot more that can be removed, like some hash functions, the entire commands lib and ipfs commands, and anything related to a disk backed datastore (badger, leveldb, etc). This is fun :D |
spent some more time on this, its really fun. This tool is really useful: https://github.com/jondot/goweight I've gotten the uncompressed wasm blob now down to 15.5MB, 3.1MB gzipped. I did this by using hectors ipfs-lite repo, and trimming a bunch of things, notably eradicating any and all imports of A few things that stick out now:
In any case, i don't intend for the hack i'm playing with to get used, but what this points out is that a reasonably sized go-ipfs wasm blob is very practical. I think that with some more work, and improvements from the go team, we can get things to be very very small! |
One very short term thing that I think would be really cool: We can compile the go yamux package to wasm, and use it in js to make communication with go nodes easier! (cc @daviddias :) ) |
Golang protobuf is 1.8MiB.
|
@whyrusleeping @magik6k @Kubuxu Is there any update on this? I see last activity was about a year ago. What is blocking this getting merged in and what do you see as the path forward? Thanks! |
The @0xProject team has added wasm support to the websocket transport (https://github.com/libp2p/go-ws-transport/). Other than that, this is just waiting for somebody to pick it up. |
Amazing idea, would be cool for both browser and nodejs, especially if typescript bindings could be generated. |
Was this idea retracted or having any roadblock? |
Part of #5694
Putting this in a PR for visibility
Currently this code is POC quality, mostly to test whether it may be actually viable to run go-ipfs in the javascript land (mostly browsers, I don't think running wasm go-ipfs in node makes much sense)
If we actually want to turn this into something usable, there will be a fair bit of cleaning up to do, but it's at lest a staring point.
How to run this thing:
go get github.com/libp2p/go-reuseport
, cd into it,git checkout feat/wasm
, cd back into go-ipfsgx-go link QmXD921xzL9EDRpD6gRm1cb7Khm8VEpZ3NT3nPK7uTX6Fq
(current go-reuseport hash)make misc/wasm/serve