Back to Rerun

Rerun architecture

ARCHITECTURE.md

0.31.418.4 KB
Original Source

Rerun architecture

This document describes the technical architecture of Rerun.

See also

The major components

Logging APIs

It all starts with logging. You can log rich data (point clouds, images, etc.) with either our Python SDK or our Rust SDK.

The logging SDK:s encodes the data using Apache Arrow (see more below).

The logging data can be written to disk as .rrd files, or transmitted over gRPC to either a Rerun Viewer or a Rerun Server.

Rerun Viewer

The Rerun Viewer is where log data is visualized. It is usually run as a native app, but can also be compiled to WebAssembly (Wasm) and run in a browser.

Native Viewer

The easiest way to launch the Viewer is directly from the logging API with rr.init("rerun_example_app", spawn=True). However, the standalone Viewer can also be run from the command line, for example to view an .rrd file: rerun mydata.rrd.

Web viewer

You can try running the Viewer in a browser using rr.serve() in Python, or using rerun --web-viewer mydata.rrd.

The web viewer consists of just a few small files - a thin .html, a .wasm blob, and an auto-generated .js bridge for the wasm. These files are served using the re_web_viewer_server crate.

The web viewer can load .rrd files (just drag-drop them into the browser), or read logging data streamed over gRPC.

.rrd files

.rrd ("Rerun Data") is just a bunch of log messages appended one after the other to a file.

NOTE: .rrd files do not yet offer full backwards or forwards compatibility. However, the current version of Rerun will always be able to open .rrd files generated by the previous version. This is not guaranteed to work for files generated with older versions.

Technologies we use

Apache Arrow

Apache Arrow 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_chunk_store.

In Rust, we use the arrow crate.

wgpu

The Rerun Viewer uses the wgpu graphics API. It provides a high-performance abstraction over Vulkan, Metal, D3D12, D3D11, OpenGLES, WebGL and WebGPU. This lets us write the same code graphics code for native as for web.

On web builds, we use WebGPU when available on the Web, but automatically fall back to a WebGL based emulation layer (with a more limited feature set).

We have written our own high-level rendering crate on top of wgpu, called re_renderer.

egui

The GUI in the Rerun Viewer is using egui, a cross-platform, immediate mode GUI.

We use eframe, the egui framework, to run egui on both native and web.

Wasm

Wasm (short for WebAssembly) 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 be 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 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 instead)
  • Use networking (use ehttp, reqwest, or ewebsock instead)
  • etc

Immediate mode

The Rerun Viewer uses an immediate mode GUI, egui. 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 "hiccups" 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.

Crates

Here is an overview of the crates included in the project:

<picture> <source media="(max-width: 480px)" srcset="https://static.rerun.io/crates/557a0aac8ea1409ea4b47e06522a6bcfdf0f90be/480w.png"> <source media="(max-width: 768px)" srcset="https://static.rerun.io/crates/557a0aac8ea1409ea4b47e06522a6bcfdf0f90be/768w.png"> <source media="(max-width: 1024px)" srcset="https://static.rerun.io/crates/557a0aac8ea1409ea4b47e06522a6bcfdf0f90be/1024w.png"> <source media="(max-width: 1200px)" srcset="https://static.rerun.io/crates/557a0aac8ea1409ea4b47e06522a6bcfdf0f90be/1200w.png"> </picture> <!-- !!! IMPORTANT!!! This image must be updated each time a crate is added/removed/updated. FigJam document: https://www.figma.com/file/Umob8ztK1HmYKLUMSq8aPb/Crates-org Update instructions: 1) Update the FigJam document 2) Select all -> right-click -> Copy as PNG 3) `pixi run upload-image --name crates` 4) Copy/paste the resulting HTML -->

SDK/CLI/Wasm top-level crates

CrateDescription
rerun-cliRerun native CLI binary crate
RerunRerun Rust SDK and Viewer shim crate
rerun_cRerun C SDK
rerun_pyRerun Python SDK
re_sdkRerun logging SDK

Viewer crates

UI crates
CrateDescription
re_arrow_uiShow arrow data in a tree of rerun list_items and format arrow with syntax highlighting.
re_blueprint_treeThe UI for the blueprint tree in the left panel.
re_chunk_store_uiA chunk store browser UI.
re_component_fallbacksProvides default fallbacks for Rerun components in the fallback provider registry.
re_component_uiProvides UI editors for Rerun component data for registration with the Rerun Viewer component UI registry.
re_dataframe_uiRich table widget over DataFusion.
re_memory_viewFlamegraph visualization for memory usage trees
re_recording_panelThe UI for the recording panel.
re_redap_browserThe UI and communication to implement the in-viewer redap server browser.
re_selection_panelThe UI for the selection panel.
re_time_panelThe time panel of the Rerun Viewer, allowing to control the displayed timeline & time.
re_viewTypes & utilities for defining View classes and communicating with the Viewport.
re_view_bar_chartA View that shows a single bar chart.
re_view_dataframeA View that shows the data contained in entities in a table.
re_view_graphA View that shows a graph (node-link diagram).
re_view_mapA View that shows geospatial data on a map.
re_view_spatialViews that show entities in a 2D or 3D spatial relationship.
re_view_tensorA View dedicated to visualizing tensors with arbitrary dimensionality.
re_view_text_documentA simple View that shows a single text box.
re_view_text_logA View that shows text entries in a table and scrolls with the active time.
re_view_time_seriesA View that shows plots over Rerun timelines.
re_viewerThe Rerun Viewer
re_viewportThe central viewport panel of the Rerun viewer.
UI support crates
CrateDescription
re_context_menuSupport crate for context menu and actions.
re_data_uiProvides UI elements for Rerun component data for the Rerun Viewer.
re_rendererA wgpu-based renderer for all your visualization needs.
re_renderer_examplesExamples for re_renderer
re_uiRerun GUI theme and helpers, built around egui
re_viewer_contextRerun Viewer state that is shared with the viewer's code components.
re_viewport_blueprintThe data model description of the viewport panel.

Application-level store

CrateDescription
re_dataframeThe Rerun public data APIs.
re_datafusionDataFusion interfaces to Rerun gRPC queries
re_entity_dbIn-memory storage of Rerun entities
re_log_encodingHelpers for encoding and transporting Rerun log messages
re_protosRerun remote store gRPC API types
re_queryQuerying data in the re_chunk_store
re_serverIn-memory data server
re_tfDealing with spatial transforms & transform frames
re_sdk_typesThe built-in Rerun data types, component types, and archetypes.

Low-level store

CrateDescription
re_chunkA chunk of Rerun data, encoded using Arrow. Used for logging, transport, storage and compute.
re_chunk_storeAn in-memory time series database for Rerun log data, based on Apache Arrow.
re_log_typesThe basic building blocks of the Rerun data types and tables.
re_sorbetRerun arrow metadata and record batch definitions.
re_types_coreThe core traits and types that power Rerun's data model.

Data flow

CrateDescription
re_redap_clientOfficial client for the Rerun Data Protocol
re_redap_testsOfficial test suite for the Rerun Data Protocol
re_data_loaderHandles loading of Rerun data from file using data loader plugins
re_data_sourceHandles loading of Rerun data from different sources
re_grpc_clientClient for the legacy StoreHub API
re_grpc_serverServer for the legacy StoreHub API
re_web_viewer_serverServes the Rerun web viewer (Wasm and HTML) over HTTP

Build support

CrateDescription
re_build_infoInformation about the build. Use together with re_build_tools
re_build_toolsbuild.rs helpers for generating build info
re_dev_toolsVarious tools for Rerun development. Each tool has a subcommand.
re_protos_builderGenerates code for Rerun remote store gRPC API
re_types_builderGenerates code for Rerun's SDKs from flatbuffers definitions.

Utilities

CrateDescription
re_analyticsRerun's analytics SDK
re_arrow_utilHelpers for working with arrow
re_authAuthentication and authorization helpers
re_backoffSimple backoff logic used for retries.
re_byte_sizeCalculate the heap-allocated size of values at runtime
re_capabilitiesCapability tokens
re_caseCase conversions, the way Rerun likes them
re_crash_handlerDetect panics and signals, logging them and optionally sending them to analytics.
re_errorHelpers for handling errors.
re_formatMiscellaneous tools to format and parse numbers, durations, etc.
re_lensesA collection of lenses for mapping component data to Rerun semantic types.
re_lenses_coreCore lens types and composable Arrow array transformations
re_logHelpers for setting up and doing text logging in the Rerun crates.
re_log_channelAn in-memory channel of Rerun data messages
re_mcapConvert MCAP into Rerun-compatible data.
re_memoryRun-time memory tracking and profiling.
re_mutexA wrapper around parking_lot::Mutex useful for debugging deadlocks.
re_perf_telemetryIn and out of process performance profiling utilities for Rerun & Redap
re_quota_channelA mpsc channel that applies backpressure based on byte size
re_ros_msgParsing and deserializing ROS messages
re_rvlCodecs for depth compression including RVL and PNG.
re_spanAn integer range that always has a non-negative length
re_string_internerYet another string interning library
re_tracingHelpers for tracing/spans/flamegraphs and such.
re_tuid128-bit Time-based Unique Identifier
re_uriParsing and constructing of Rerun URIs
re_videoVideo decoding library

Test crates

CrateDescription
re_test_contextProvides a test context that builds on `re_viewer_context.
re_test_viewportExtends the re_test_context with viewport-related features.

Deprecated crates

CrateDescription
re_typesOld name of re_sdk_types

Dependencies and docs

In order to get a dependency graph for our in-house crates and their docs, we recommend you run:

cargo install cargo-depgraph
cargo depgraph --all-deps --workspace-only --all-features --dedup-transitive-deps | dot -Tpng > /tmp/rerun-deps.png
open /tmp/rerun-deps.png

and:

cargo doc --no-deps --open

and then browse through the re_* crates.