Skip to content

Commit

Permalink
More migration from old ARCHITECTURE.md
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Aug 22, 2023
1 parent 4026927 commit 8dfeb5e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 52 deletions.
47 changes: 0 additions & 47 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,50 +35,3 @@ The web viewer can load `.rrd` files (just drag-drop them into the browser), or
`.rrd` ("**R**e**r**un **D**ata") is just a bunch of log messages appended one after the other to a file.

NOTE: `.rrd` files do not yet guarantee any backwards or forwards compatibility. One version of Rerun will likely not be able to open an `.rrd` file generated by another Rerun version.



## Technologies we use
### Apache Arrow
[Apache Arrow](https://arrow.apache.org/) is a language-independent columnar memory format for arbitrary data. We use it to encode the log data when transmitting it over the network or storing it in an `.rrd` file. We also use it in our in-RAM data store, [`re_arrow_store`](crates/re_arrow_store/README.md).

In rust, we use the [`arrow2` crate](https://crates.io/crates/arrow2).

### `wgpu`
The Rerun Viewer uses the [`wgpu`](https://github.com/gfx-rs/wgpu) graphics API. It provides a high-performance abstraction over Vulkan, Metal, D3D12, D3D11, OpenGLES, WebGL and [WebGPU](https://en.wikipedia.org/wiki/WebGPU). This lets us write the same code graphics code for native as for web.

We use the WebGL backend when compiling for web. Once WebGPU is available in most browsers, we can easily switch to it for a nice performance boost!

We have written our own high-level rendering crate on top of `wgpu`, called [`re_renderer`](crates/re_renderer/README.md).

### `egui`
The GUI in the Rerun Viewer is using [`egui`](https://www.egui.rs/), a cross-platform, [immediate mode GUI](https://github.com/emilk/egui#why-immediate-mode).

We use [`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe), the egui framework, to run `egui` on both native and web.


### Wasm
Wasm (short for [WebAssembly](https://webassembly.org/)) is a binary instruction format supported by all major browser.
The Rerun Viewer can be compiled to Wasm and run in a browser.

Threading support in Wasm is nascent, so care must we taken that we don't spawn any threads when compiling for `wasm32`.

Wasm has no access to the host system, except via JS calls (something that may change once [WASI](https://wasi.dev/) rolls out), so when compiling for `wasm32` you can NOT use the Rust standard library to:
* Access files
* Read environment variables
* Get the current time (use [`instant`](https://crates.io/crates/instant) instead)
* Use networking (use [`ehttp`](https://github.com/emilk/ehttp), [`reqwest`](https://github.com/seanmonstar/reqwest), or [`ewebsock`](https://github.com/rerun-io/ewebsock) instead)
* etc


## Immediate mode
The Rerun Viewer uses an [immediate mode GUI](https://github.com/emilk/egui#why-immediate-mode), [`egui`](https://www.egui.rs/). This means that each frame the entire GUI is being laid out from scratch.

In fact, the whole of the Rerun Viewer is written in an immediate mode style. Each rendered frame it will query the in-RAM data store, massage the results, and feed it to the renderer.

The advantage of immediate mode is that is removes all state management. There is no callbacks that are called when some state has already changed, and the state of the blueprint is always in sync with what you see on screen.

Immediate mode is also a forcing function, forcing us to relentlessly optimize our code.
This leads to a very responsive GUI, where there is no "hickups" when switching data source or doing time scrubbing.

Of course, this will only take us so far. In the future we plan on caching queries and work submitted to the renderer so that we don't perform unnecessary work each frame. We also plan on doing larger operation in background threads. This will be necessary in order to support viewing large datasets, e.g. several million points. The plan is still to do so within an immediate mode framework, retaining most of the advantages of stateless code.
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,17 @@ You can set up [`sccache`](https://github.com/mozilla/sccache) to speed up re-co

### Other
You can view higher log levels with `export RUST_LOG=debug` or `export RUST_LOG=trace`.

## Wasm
Wasm (short for [WebAssembly](https://webassembly.org/)) is a binary instruction format supported by all major browser.
The Rerun Viewer can be compiled to Wasm and run in a browser.

Threading support in Wasm is nascent, so care must we taken that we don't spawn any threads when compiling for `wasm32`.

Wasm has no access to the host system, except via JS calls (something that may change once [WASI](https://wasi.dev/) rolls out), so when compiling for `wasm32` you can NOT use the Rust standard library to:
* Access files
* Read environment variables
* Get the current time (use [`instant`](https://crates.io/crates/instant) instead)
* Use networking (use [`ehttp`](https://github.com/emilk/ehttp), [`reqwest`](https://github.com/seanmonstar/reqwest), or [`ewebsock`](https://github.com/rerun-io/ewebsock) instead)
* etc

36 changes: 31 additions & 5 deletions docs/content/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,34 @@ Users can extend the Viewer with arbitrary visualizations of their own making.

*Message: show future-proofness by showing strong foundations and strong reasons to use them.*

Check warning on line 50 in docs/content/architecture.md

View workflow job for this annotation

GitHub Actions / Spellcheck

Unknown word (proofness)

- [Apache Arrow](https://arrow.apache.org)
- **Rust**: the only mainstream language that is both fast and safe. https://www.rerun.io/blog/why-rust
- We use [WebAssembly](https://webassembly.org) to get the viewer running at high speeds inside a browser or anywhere you can embed a web-view. For the native viewer we compile natively (no need for Electron!)
- [egui](https://www.egui.rs)
- [wgpu](https://wgpu.rs)
### [Apache Arrow](https://arrow.apache.org/overview/)
Arrow is a language-independent columnar memory format for arbitrary data. We use it to encode the log data on-the-wire and in our data store.

### Rust
The only mainstream language that is both fast and safe. https://www.rerun.io/blog/why-rust

### Wasm
We use [Wasm](https://webassembly.org) to get the viewer running at high speeds inside a browser or anywhere you can embed a web-view. For the native viewer we compile natively (no need for Electron!)

### `egui``
[egui](https://www.egui.rs) is an easy-to-use cross-platform, [immediate mode GUI](https://github.com/emilk/egui#why-immediate-mode) created by our CTO.

### `wgpu``
[wgpu](https://wgpu.rs) provides a high-performance abstraction over Vulkan, Metal, D3D12, D3D11, OpenGLES, WebGL and [WebGPU](https://en.wikipedia.org/wiki/WebGPU). This lets us write the same code graphics code for native as for web.

Check warning on line 65 in docs/content/architecture.md

View workflow job for this annotation

GitHub Actions / Spellcheck

Unknown word (GLES)

We use the WebGL backend when compiling for web. Once WebGPU is available in most browsers, we can easily switch to it for a nice performance boost!

We have written our own high-level rendering crate on top of `wgpu`, called [`re_renderer`](crates/re_renderer/README.md).


## Immediate mode
The Rerun Viewer uses an [immediate mode GUI](https://github.com/emilk/egui#why-immediate-mode), [`egui`](https://www.egui.rs/). This means that each frame the entire GUI is being laid out from scratch.

In fact, the whole of the Rerun Viewer is written in an immediate mode style. Each rendered frame it will query the in-RAM data store, massage the results, and feed it to the renderer.

The advantage of immediate mode is that is removes all state management. There is no callbacks that are called when some state has already changed, and the state of the blueprint is always in sync with what you see on screen.

Immediate mode is also a forcing function, forcing us to relentlessly optimize our code.
This leads to a very responsive GUI, where there is no "hickups" when switching data source or doing time scrubbing.

Check warning on line 80 in docs/content/architecture.md

View workflow job for this annotation

GitHub Actions / Spellcheck

Unknown word (hickups)

Of course, this will only take us so far. In the future we plan on caching queries and work submitted to the renderer so that we don't perform unnecessary work each frame. We also plan on doing larger operation in background threads. This will be necessary in order to support viewing large datasets, e.g. several million points. The plan is still to do so within an immediate mode framework, retaining most of the advantages of stateless code.

0 comments on commit 8dfeb5e

Please sign in to comment.