Velox

OLAP

Velox is a reusable vectorized database execution engine. It can be used to build compute engines focused on analytical workloads, including batch (Spark, Presto), interactive (PyVelox), stream, log processing, and AI/ML.

Unlike a complete database, Velox cannot be used directly by end-users. Rather, it is designed to be a general-purpose component to handle execution that database developers can use in their systems.

History

Meta's data infrastructure contains dozens of specialized data computation engines, which have been largely developed independently. Maintaining and enhancing each of them can be difficult, especially considering the rapid change of workload requirements and hardware condition.

Velox is created in 2020 and open-sourced in 2021 to address this problem as a unified execution engine. It is under active development, but it is already in various stages of integration with some systems, including Presto, Spark, and PyTorch (the latter through a data preprocessing library called TorchArrow), etc. Additional contributions were provided by Intel, ByteDance, and Ahana.

Checkpoints

Not Supported

Does not support database checkpoint. However, there is some action to make the executor more resilient. When memory allocation fails in a task, the current state can be spilled to disk and the task can be paused and return a continuable VeloxPromise.

Compression

Run-Length Encoding Null Suppression Prefix Compression

Vectors in Velox is arrow compatible with slight difference. During execution, the vector being passed around may be compressed based on its value feature. There are flat vector, dictionary vector, lazy vector or constant vector, etc. Vectors typically contains four lists: Null Value Mask, Offsets, Sizes, Elements.

For strings, it adopts the Umbra way of store 4-byte string prefix plus 8-byte pointer to BLOB buffer.

Data Model

Relational

Velox uses Relational model. Inside the Velox dataframe abstraction, there can be scalar values including numbers of different length and precision, strings (VARCHAR or VARBINARY), timestamps of different precision and pointer to functions. Complex types in Velox include arrays, maps, and structs.

Datatable can contain integers and floats of different precision, strings (both varchar and varbinary types), dates, timestamps, and functions (lambdas). It also supports complex types such as arrays, fixed-size arrays (used to implement ML tensors), maps, and structs.

Velox also provides a data type called OPAQUE that can wrap arbitrary C++ data structures.

Foreign Keys

Not Supported

Isolation Levels

Not Supported

Logging

Not Supported

Parallel Execution

Bushy

The top level concept in Velox execution is the query plan, a.k.a Task. Task can then be converted to multiple stacked pipelines, which is similar to idea of pipeline in Morsel-Driven Parallelism. Each Pipeline is consist of multiple Nodes, such as HashJoinNode, CrossJoinNode, MergeJoinNode, LocalMergeNode, LocalPartitionNode and TableScanNode. Nodes complete their execution using Operators and Drivers, which are both created by the Task. Each Driver is a thread and it takes over the ownership of the Operator from Task. One node can have multiple Drivers working at the same time to achieve inner-query parallelism.

Query Compilation

Code Generation

Right now, Velox experimentally supports query compilation through Codegen. It will transpile the query plan (Task) into C++ code and compile it to shared library using regular compilers (gcc / clang). This shared library can be linked to the main process at runtime.

Query Interface

Custom API

Users should use C++ for native support. Velox is also built as binary wheels for PyVelox (the Velox Python Bindings).

Storage Format

Apache Arrow

Storage Model

Decomposition Storage Model (Columnar)

As an execution engine designed for OLAP systems, DBMS is designed mostly for DSM storage model.

Stored Procedures

Supported

Velox exposes C++ scalar UDF function API to the user. Users can write business logic based on a template, and Velox will help compile arithmetic functions to SIMD automatically. It also supports user-defined aggregation functions.

System Architecture

Embedded

Velox focuses on computation efficiency on single computer. Velox itself is an embedded engine. However, depending on the host system, it can also be expanded to run as standalone program. Prestissimo is the example of such practice.

Views

Materialized Views

There is materialized view between pipelines (thread-level) stored in local exchange queues. Also, there is materialized view between tasks (computer-level) maintaining by exchange client.

Velox Logo
Website

https://velox-lib.io/

Source Code

https://github.com/facebookincubator/velox

Tech Docs

https://facebookincubator.github.io/velox/

Developer

Meta

Country of Origin

US

Start Year

2020

Project Type

Industrial Research, Open Source

Written in

C++

Supported languages

C++, Python

Operating Systems

Linux, OS X

Licenses

Apache v2