boinc icon indicating copy to clipboard operation
boinc copied to clipboard

Enable browser-based computing in BOINC

Open davidpanderson opened this issue 6 years ago • 24 comments

It's possible to do scientific computing with GPUs using WebGL, on a variety of devices including phones. The easiest way to do this is from Javascript running in a browser.

Here's an idea: write a lightweight "BOINC client" in JS, which gets jobs from BOINC servers via the scheduler RPC protocol (or maybe a JSON-ized version of it). The jobs would be JS programs, possibly using WebGL.

Note: modern browsers have a provision for "background jobs" that run independently of browser windows.

davidpanderson avatar Apr 03 '19 23:04 davidpanderson

Some people have talked about compiling BOINC (and apps) with Emscripten to run them on browsers. I don't know how far that work has progressed. I can't remember any status updates right now.

JuhaSointusalo avatar Apr 04 '19 16:04 JuhaSointusalo

JavaScript itself is slow. Machine-converted code from c++ with its complexity to JavaScript, I'm afraid, will produce very slow solution. So personally I'd rather create JS client from scratch than use Emscripten. But as a fast first solution is fine, I believe. Maybe later we could find someone who could do this from scratch on JS (I believe it's easier than find someone to build c++ code on MacOS 😉

чт, 4 апр. 2019 г. в 19:26, Juha Sointusalo [email protected]:

Some people have talked about compiling BOINC (and apps) with Emscripten to run them on browsers. I don't know how far that work has progressed. I can't remember any status updates right now.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BOINC/boinc/issues/3086#issuecomment-479968714, or mute the thread https://github.com/notifications/unsubscribe-auth/ADFZoVbcRylT66GeXi1rumdc-Wl_xb25ks5vdie2gaJpZM4cboTe .

-- Best regards, Vitalii Koshura

Sent via iPhone

AenBleidd avatar Apr 04 '19 16:04 AenBleidd

I do remember playing Doom (Quake? Wolfenstein?) and running Linux on browser. Emscriptem docs claim

Emscripten generates fast code! Its default output format is asm.js , a highly optimizable subset of JavaScript that can execute at close to native speed in many cases (check out the current benchmark results or run the benchmark tests yourself).

Of course they say good things about themselves and I can't really understand the linked benchmarks. But I certainly wouldn't shrug it off without benchmarking our apps first.

JuhaSointusalo avatar Apr 04 '19 16:04 JuhaSointusalo

Emscripten can convert to Web Assembly as well. While not as fully universal, it's on the major browsers and runs at a much faster speed. Multithreading is not actually supported in js, but Chrome does have a test of it (on production) in WebAssembly so that would allow for easier porting.

RoboticMind avatar Apr 30 '19 23:04 RoboticMind

What's the use case of a browser-based client? It's temporary, and slower then a native client. The only thing I can think of is running boinc temporary on a machine which I don't have permission to install the boinc permanently.

adamradocz avatar May 24 '19 11:05 adamradocz

What's the use case of a browser-based client? It's temporary, and slower then a native client. The only thing I can think of is running boinc temporary on a machine which I don't have permission to install the boinc permanently.

This could also be used to run BOINC applications on platforms that don't natively support them (for example, you could use this to run BOINC on a Windows Phone, or on a Chromebook that doesn't have the new native Linux apps support).

Also, while it would indeed be worse in terms of performance than native code, it may not actually end up being as bad as you might think. WebAssembly and asm.js are actually surprisingly fast if done right (yes, it's not native speeds, but it's exponentially faster than JavaScript).

Ferroin avatar May 24 '19 11:05 Ferroin

Windows Phone is dead. Can't Chromebook run Android Boinc?

adamradocz avatar May 24 '19 15:05 adamradocz

@adamradocz They were just the first two platforms that came to mind, there are of course other platforms out there that are not widely supported by BOINC applications that could benefit from this.

Alternatively though, if combined with a headless web browser with some extra stuff added in, this could potentially be used as a much more portable alternative to the current VM app functionality in BOINC (the VirtualBox functionality is still locked to the CPU architecture, this would allow the app to not care about that).

Ferroin avatar May 24 '19 16:05 Ferroin

Running on browser would allow iOS to use it which would allow more people to use BOINC. There's also the ease of use to it. If I'm not technical, going to a website is much easier than installing something. It might not seem like a whole lot different but I used to use folding@home over BOINC because it ran in the browser and that was easier for me at the time.

RoboticMind avatar May 24 '19 16:05 RoboticMind

@Ferroin Make sense. @RoboticMind For iOS, there's a similar app like boinc, called DreamLab. I think, visiting a website every day is tedious, so contributing in such a way, you have to be very conscious about the cause. But I accept your view.

adamradocz avatar May 24 '19 17:05 adamradocz

It looks like WebAssemly is the future. Maybe worth considering converting the client to Wasm, rather than JavaScript. It will be much faster, especially in the future, when the WebAssemly gets more optimization. A Real-World WebAssembly Benchmark

adamradocz avatar May 30 '19 13:05 adamradocz

I played around compiling with emscripten emsdk

Basically source ./emsdk_env.sh and emconfigure ./configure and emmake make

OpenSSL compile works with no-asm no-shared -D__STDC_NO_ATOMICS__=1 https://github.com/openssl/openssl/issues/5443

libcurl doesn't seem to work with emsdk at the moment, at least no one documents it. ./configure script fails at compiler does not halt on function prototype mismatch, disable that in configure.ac and another roadblock with cannot find function connect in libraries Maybe need to rewrite libcurl part with WebAssembly equivalent

zlib is provided by emsdk with linker flag -s USE_ZLIB=1

After that maybe can compile boinc with emsdk to create wasm executable

truboxl avatar Apr 28 '20 03:04 truboxl

After looking further into this, I think emsdk can be used to create wasm-based science apps. The client however probably need to be rewrite as a simple JS-based program. Pthreads, POSIX ports and other hostinfo features maybe problematic through different web browsers implementations so fat native wasm-based client is not going to happen. Node.js runtime can be used for running wasm and its fairly stable I think, need more testing.

We may try package node.js runtime + wasm-based science apps for testing on current platforms. Probably in the future its possible to run on web browsers, or maybe now if someone knows.

truboxl avatar Aug 27 '20 08:08 truboxl

It might also be possible to include a WASM "engine" in the BOINC client.

davidpanderson avatar Aug 27 '20 19:08 davidpanderson

Wasm-based apps are highly portable. It can probably be deployed in some edge devices (routers, nas, IoT with somehow powerful computation capabilities, etc).

h4x3rotab avatar Nov 04 '20 17:11 h4x3rotab

JavaScript itself is slow. Machine-converted code from c++ with its complexity to JavaScript, I'm afraid, will produce very slow solution.

that aged well lmaoo

darthnithin avatar Nov 11 '20 04:11 darthnithin

I don't think WASM is slow. It has nothing to do with Javascript as well

h4x3rotab avatar Nov 11 '20 10:11 h4x3rotab

I don't think WASM is slow. It has nothing to do with Javascript as well

Could you please share any comparison if you have one? That would be great.

AenBleidd avatar Nov 11 '20 10:11 AenBleidd

@AenBleidd Webassembly isn't really javascript. from my understanding you can compile to it from C(#)/(++) to use traditionally desktop libraries on the web. Also from what I understand the performance it great and near native.

darthnithin avatar Nov 19 '20 21:11 darthnithin

WASM is completely unrelated to JS other than being a web platform. It’s typically compiled from some other language (most commonly Rust from what I’ve seen, but C/C++ work as well).

Performance is indeed near-native, though it has some caveats, namely that initialization overhead for a WASM context is non-negligible and anything that actually hits Web APIs is essentially no faster than well optimized JS (the API itself is slow, not the code accessing it), though neither of those are likely to matter for the type of usage that would be required by BOINC.

Ferroin avatar Nov 20 '20 12:11 Ferroin

It might also be possible to include a WASM "engine" in the BOINC client.

To addon, yeah it is possible to ship other engines besides Node.js, such as those described in https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone

It will be better if there's some project willing to give out source code for experimentation to kick start this initiative...

truboxl avatar Feb 20 '21 11:02 truboxl

I thnk the MLC client (or at least a usable subset of it) could be built to target WASM and be a decent testbed.

clemej avatar Jul 21 '21 17:07 clemej

As someone who is not a coder but has been a long time boinc user and webassembly fan it seems like idea of a webassembly gui client with its write once deploy everywhere would certainly free up you alls limited time for other boinc issues. Could use webassembly either in a browser or WAVM goal is to run webassembly on a virtual machine. https://github.com/WAVM/WAVM

newblar avatar Jul 23 '21 14:07 newblar

Currently vlc is also working to port to webassembly

newblar avatar Jul 23 '21 14:07 newblar