• Stars
    star
    3,149
  • Rank 14,275 (Top 0.3 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Browsix is a Unix-like operating system for the browser.

Browsix - Bringing Unix to the Browser

NPM version david-dm-status-badge david-dm-status-badge

While standard operating systems like Unix make it relatively simple to build complex applications, web browsers lack the features that make this possible. This project is Browsix, a JavaScript-only framework that brings the essence of Unix to the browser. Browsix makes core Unix features available to web applications (including pipes, processes, signals, sockets, and a shared file system) and extends JavaScript runtimes for C, C++, Go, and Node.js programs so they can run in a Unix-like environment within the browser. Browsix also provides a POSIX-like shell that makes it easy to compose applications together for parallel data processing via pipes.

For more details, check out our tech report (PDF).

Another way to think about this is that modern web applications are multi-process by nature - the client and some of the application logic lives in the browser, and some of it lives in the cloud, often implemented as microservices.

Browsix lets you rethink the boundary between code executing in the browser vs. server-side, while taking advantage of the multi-core nature of modern computing devices.

Browsix enables you to compose the in-browser part of your web applications out of processes. Processes behave as you would expect coming from Unix: they run in parallel with the main browser thread, can communicate over pipes, sockets, or the filesystem, and can create subprocesses. This process model is implemented on top of existing browser APIs, like web workers, so it works in all modern browsers. Browsix applications can be served statically or over a CDN.

The Browsix Shell

As a proof of concept, we've implemented a POSIX-like shell on top of Browsix, along with an implementation of a number of standard Unix utilities (cat, tee, echo, sha1sum, and friends). The utilities are all standard node programs that will run directly under node, or in the browser under Browsix. Individual commands are executed in their own workers, and piping works as expected:

shell

Try it out here: live demo!

Meme creator

Browsix is useful for more than web terminals. With Browsix, you can run Go microservices directly in the browser! As an example, we have implemented a meme creator, that lets you create memes (sometimes known as image macros) with (hopefully) humorous text on top of several images. We wrote this as a standard REST service in Go, accepting the text and image type as parameters, and returning a PNG. We used our modified GopherJS compiler to compile the Go service (including all dependencies, such as the TrueType font renderer and image manipulation libraries) to JavaScript, and Browsix to run this JavaScript as a process in a background Web Worker. We then dynamically route requests to either this in-browser server or a remote server depending on user agent and network connectivity.

Details

Browsix currently supports running node.js, Go, and C/C++ programs. It supports Go with a modified GopherJS compiler (requires a host Go 1.6 install for now), and C/C++ with modifications to Emscripten.

Browsix-SPEC

Browsix supports executing SPEC CPU2006 and SPEC CPU2017 benchmarks using Browsix-SPEC interface.

Using Browsix

There are two parts to Browsix: build tooling (the modified Go + C compilers) and runtime support (the kernel + Browsix APIs).

Get browsix through npm:

    $ npm install --save browsix

Building & Testing

Browsix requires nodejs 4.3.0 or later, which is more recent than the version packaged in Ubuntu Wiley. To get a recent version of node, follow the instructions on the node.js website. If you don't know whether you should choose node 4.x or 5.x, choose 4.x (it is the long-term support branch).

Browsix has three other dependencies: git, npm (usually installed along with node), and make, and builds on OSX and Linux systems. Once you have those dependencies:

    $ git clone --recursive https://github.com/plasma-umass/browsix
    $ cd browsix
    $ make test-once serve

This will pull the dependencies, build the runtime and all the utilities, run a number of tests in either Firefox or Chrome, and then launch a copy of the shell served locally.

Dockerfile

$ ./docker/build.sh
....
root@3695ed0cdf45:~/browsix# make test-once serve
  TEST
[13:07:00] Using gulpfile ~/browsix/gulpfile.js
[13:07:00] Starting 'copy-node-kernel'...
[13:07:00] Starting 'copy-node'...
[13:07:00] Starting 'lint-kernel'...
[13:07:00] Starting 'lint-browser-node'...
[13:07:00] Starting 'lint-bin'...
[13:07:00] Starting 'lint-syscall-api'...
[13:07:00] Finished 'copy-node-kernel' after 82 ms
[13:07:02] Finished 'lint-syscall-api' after 1.61 s
[13:07:04] Finished 'lint-kernel' after 3.72 s
[13:07:05] Finished 'lint-browser-node' after 4.46 s
[13:07:05] Finished 'lint-bin' after 5.08 s
[13:07:05] Starting 'build-bin'...
[13:07:06] Finished 'copy-node' after 5.16 s
[13:07:06] Starting 'build-kernel'...
[13:07:06] Starting 'build-browser-node'...
...

Building and using Browsix-SPEC

After building Browsix, build Browsix-SPEC through make:

make browsix-spec

Follow the instructions in browsix-spec.md.

In-browser node limitations

Browsix's browser-node implementation has an important to understand limitation: you must explicitly call process.exit(). Without this, utilities will work under real-node, but appear to hang under browser-node. This is not an intrinsic limitation, but it is a hairy implementation detail -- node exits when the event loop is empty, and there are no active timers or network callbacks. For us to do the same thing means we need to hook setTimeout and any other functions that take callbacks to ensure we don't exit early.

Documentation

For a high-level overview of the system design and architecture, please see this document.

Contributing

You're interested in contributing? That's great!

The process is similar to other open-source projects hosted on github:

  • Fork the repository
  • Make some changes
  • Commit your changes with a descriptive commit message
  • Open a pull request

Contact

If you have questions or problems, please open an issue on this repository (plasma-umass/browsix).

Open Source

This project is licensed under the MIT license, but also incorporates code from other sources.

Browsix uses BrowserFS for its filesystem, which is primarily MIT licensed.

browser-node's nextTick implementation comes from the acorn project, released under the MIT license.

A large portion of browser-node is the node standard library, which is MIT licensed.

Functions to convert buffers to utf-8 strings and back are derivative of browserify implementations (ported to TypeScript), MIT licensed as well.

More Repositories

1

scalene

Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python with AI-powered optimization proposals
Python
12,131
star
2

coz

Coz: Causal Profiling
C
4,024
star
3

doppio

Breaks the browser language barrier (includes a plugin-free JVM).
TypeScript
2,150
star
4

Mesh

A memory allocator that automatically reduces the memory footprint of C/C++ applications.
C++
1,618
star
5

ChatDBG

ChatDBG - AI-assisted debugging. Uses AI to answer 'why'
C++
772
star
6

slipcover

Near Zero-Overhead Python Code Coverage
Python
485
star
7

BLeak

BLeak: Automatically Debugging Memory Leaks in Web Applications
TypeScript
408
star
8

cwhy

"See why!" Explains and suggests fixes for compile-time errors for C, C++, C#, Go, Java, LaTeX, PHP, Python, Ruby, Rust, and TypeScript
C++
272
star
9

sqlwrite

SQLwrite: AI in your DBMS! Automatically converts natural language queries to SQL.
C
106
star
10

NextDoor

Graph Sampling using GPU
Cuda
49
star
11

DataDebug

Excel 2010/2013 add-in that automatically finds errors in spreadsheets
C#
46
star
12

coverup

Automatic AI-powered test suite generator
Python
37
star
13

systemgo

Init system in Go, intended to run on Browsix and other Unix-like OS. Part of GSoC 2016 project.
Go
36
star
14

sheriff

Sheriff consists of two tools: Sheriff-Detect, a false-sharing detector, and Sheriff-Protect, a false-sharing eliminator that you can link with your code to eliminate false sharing.
C++
29
star
15

DoubleTake

Evidence-based dynamic analysis: a fast checker for memory errors.
C
21
star
16

commentator

Automatically comments Python code, adding docstrings and type annotations, with optional translation to other languages.
Python
20
star
17

Predator

Predator: Predictive False Sharing Detection
C
19
star
18

memory-landscape

The space of memory management research and systems produced by the PLASMA lab (https://plasma-umass.org).
16
star
19

snakefish

parallel Python
Python
13
star
20

entroprise

measure entropy of memory allocators
C++
12
star
21

parcel

An Excel formula parser
C#
12
star
22

Rehearsal

Rehearsal: A Configuration Verification Tool for Puppet
Scala
12
star
23

Hound

Hound memory leak detector
C++
11
star
24

smash-project

Smash compressing allocator project
C++
10
star
25

browsix-spec

JavaScript
9
star
26

Archipelago

Archipelago memory allocator
C
8
star
27

simplesocket

A simple socket wrapper for C++.
C++
8
star
28

pythoness

Pythoness: use natural language to define Python functions.
Python
7
star
29

compsci631

Support code for Programming Languages (COMPSCI631)
OCaml
7
star
30

Tortoise

Tortoise: Interactive System Configuration Repair
Scala
6
star
31

scalene-gui

Scalene web GUI
JavaScript
5
star
32

llm-utils

Utilities for our LLM projects (CWhy, ChatDBG, ...).
Python
5
star
33

transparentFS

TransparentFS code, paper, and slides
C
5
star
34

homebrew-scalene

Homebrew tap for Scalene (emeryberger/scalene)
Ruby
4
star
35

GSoC

Description of our Google Summer of Code projects for 2015
4
star
36

vam

Implementation from "A Locality-Improving Dynamic Memory Allocator", Feng and Berger, MSP 2005
C++
4
star
37

HeapToss

HeapToss is an LLVM compiler pass that moves stack variables that may escape their declaring function's context into the heap.
3
star
38

pytest-cleanslate

Python
3
star
39

jsvm

JavaScript
2
star
40

GSoC-2013

Google Summer of Code 2013
2
star
41

plasma-umass.github.io

home page
HTML
2
star
42

spl

Rust
2
star
43

doppio_jcl

Scripts that produce a version of the Java Class Library and Java Home in a way that is compatible with DoppioJVM.
TypeScript
2
star
44

nextdoor-eurosys21

HTML
1
star
45

mesh-testsuite

C
1
star
46

ChatSheet

Python
1
star
47

custom-public

Jupyter Notebook
1
star
48

proto

probabilistic race tolerance
C
1
star
49

wasm-gc-template

C++
1
star
50

typissed

Generates MTurk typo jobs
C#
1
star
51

scalene-benchmarks

Benchmarks comparing Scalene with other commonly-used profilers
Python
1
star
52

emcc_control

C
1
star
53

transparentMM

Transparent memory management
1
star