plasma-umass / browsix

Browsix is a Unix-like operating system for the browser.
Other
3.15k stars 181 forks source link

Implement synchronous syscall mechanism #36

Closed bpowers closed 8 years ago

bpowers commented 8 years ago

(this is safe to merge in -- unit tests pass and the kernel supports both async + sync syscalls after this PR).

This allows us to run standard, asm.js programs compiled with Emscripten under Browsix, without pulling in the emterpreter. It requires SharedArrayBuffer support, which is currently shipping in beta versions of Firefox and Chrome (but is disabled by default).

To enable shared array buffers, start Chrome from the command line as:

$ chrome --js-flags=--harmony-sharedarraybuffer --enable-blink-feature=SharedArrayBuffer

It doesn't yet work in Firefox, as Firefox doesn't correctly implement the spec (see bug). We can work around this by temporarily copying out of the shared array into a regular ArrayBuffer for the lifetime of the system call - I'll do this as a followup.

Performance of pdflatex main.tex:

native: .4 seconds emterpreted browsix: > 20 seconds sync browsix: 4 seconds (~1 second is v8 initial compilation).

The main performance cost at this point I think is ~2200 read() syscalls. I think we should be able to improve this further by: increasing the size of the read buffer in tex (currently 1024 bytes, up it to 4096), and decreasing the size of the pdflatex.map font map file -- it is 1.4 MB, generated on my linux latop. I think we should be able to regenerate it to ignore non-tex fonts.

The emscripten work is in this branch. Unlike my last take, programs compiled with this Browsix sync syscall support will also run under node, and in the browser as regular emscripten libraries.

emeryberger commented 8 years ago

Super cool, great work.