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.
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.
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.
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.
Hash Join Sort-Merge Join Broadcast Join Semi Join
Velox supports most common join rules. For Hash Joins and Semi Joins, Velox use either partitioned and broadcast distribution strategy.
During Hash Join when the selectivity of the join keys on the build side is high and the table can fit into memory, Velox will use Broadcast distribution strategy, i.e. enforce "Dynamic Filter Pushdown" to the Tablescan node.
Velox also supports inner and left merge join for the case where both sides are sorted on the join keys.
If the join condition is IN
in Semi joins and Anti Joins, Velox will maintain a null-mask to distinguish it with EXISTS
case.
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.
Users should use C++ for native support. Velox is also built as binary wheels for PyVelox (the Velox Python Bindings).
Decomposition Storage Model (Columnar)
As an execution engine designed for OLAP systems, DBMS is designed mostly for DSM storage model.
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.
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.
https://github.com/facebookincubator/velox
https://facebookincubator.github.io/velox/
Meta
2020
Industrial Research, Open Source