Aligning Velox and Apache Arrow: In the direction of composable knowledge administration

  • We’ve partnered with Voltron Data and the Arrow group to align and converge Apache Arrow with Velox, Meta’s open supply execution engine.
  • Apache Arrow 15 contains three new format layouts developed via this partnership: StringView, ListView, and Run-Finish-Encoding (REE).
  • This new convergence helps Meta and the bigger group construct knowledge administration techniques which can be unified, extra environment friendly, and composable.

Meta’s Knowledge Infrastructure groups have been rethinking how data management systems are designed. We wish to make our data management systems more composable – which means that as an alternative of individually creating techniques as monoliths we establish widespread parts, issue them out as reusable libraries, and leverage widespread APIs and requirements to extend the interoperability between them. 

As we decompose our giant, monolithic techniques right into a extra modular stack of reusable parts, open requirements, reminiscent of Apache Arrow, play an necessary function for interoperability of those parts. To additional our efforts in making a extra unified knowledge panorama for our techniques in addition to these within the bigger group, we’ve partnered with Voltron Knowledge and the Arrow group to converge Apache Arrow’s open supply columnar layouts with Velox, Meta’s open supply execution engine.

The consequence combines the effectivity and agility provided by Velox with the widely-used Apache customary.  

Why we’d like a composable knowledge administration system

Meta’s knowledge engines help large-scale workloads that embody processing giant datasets offline (ETL), interactive dashboard technology, advert hoc knowledge exploration, and stream processing. Extra just lately, a wide range of characteristic engineering, knowledge preprocessing, and coaching techniques had been constructed to help our quickly increasing AI/ML infrastructure. To make sure our engineering groups can effectively preserve and improve these engines as our merchandise evolve, Meta has began a collection of initiatives aimed toward growing our engineering effectivity by minimizing the duplication of labor, bettering the expertise of inside knowledge customers via extra constant semantics throughout these engines, and, finally, accelerating the tempo of innovation in knowledge administration. 

An introduction to Velox

Velox is the primary undertaking in our composable knowledge administration system program. It’s a unified execution engine, carried out as a C++ library, aimed toward changing the very processing core of many of those knowledge administration techniques – their execution engine.

Velox improves the effectivity of those techniques by offering a unified, state-of-the-art implementation of options and optimizations that had been beforehand solely obtainable in particular person engines. It additionally improves the engineering effectivity of our group since these options can now be written as soon as, in a single library, and be (re-)used all over the place.

Velox is at present in several levels of integration in additional than 10 of Meta’s knowledge techniques. Now we have noticed 3-10x efficiency improvements in integrations with well-known techniques within the business like Apache Spark and Presto. 

We open-sourced Velox in 2022. At this time, it’s developed in collaboration with greater than 200 particular person contributors world wide from greater than 20 firms. 

Open requirements and Apache Arrow

As a way to allow interoperability with different parts, a composable knowledge administration system has to know widespread storage (file) codecs, community serialization protocols, desk APIs, and have a unified approach of expressing computation. Oftentimes these parts should straight share in-memory datasets with one another, for instance, when transferring knowledge throughout language boundaries (C++ to Java or Python) for environment friendly UDF help.

Our focus is to make use of open requirements in these APIs as typically as potential. Apache Arrow is an open supply in-memory format customary for columnar knowledge that has been extensively adopted within the business. In a approach, Arrow could be seen because the layer beneath Velox: Arrow describes how columnar knowledge is represented in reminiscence; Velox gives a collection of execution and useful resource administration primitives to course of this knowledge.

Though the Arrow format predates Velox, we made a aware design choice whereas creating Velox to increase and deviate from the Arrow format, making a format we name Velox Vectors. The aim was to speed up the information processing operations generally present in our workloads in ways in which weren’t potential utilizing Arrow. Velox Vectors supplied the effectivity and agility we have to transfer quick, however in return created a fragmented area with restricted part interoperability. 

To bridge this hole and create a extra unified knowledge panorama for our techniques and the group, we partnered with Voltron Knowledge and the Arrow group to align and converge these two codecs. After a yr of labor, the brand new Apache Arrow launch, Apache Arrow 15.0.0, contains three new format layouts impressed by Velox Vectors: StringView, ListView, and Run-Finish-Encoding (REE).

Arrow 15 not solely permits environment friendly (zero-copy) in-memory communication throughout parts utilizing Velox and Arrow, but additionally will increase Arrow’s applicability in trendy execution engines, unlocking a wide range of use circumstances throughout the business. 

Particulars of the Arrow and Velox format

Each Arrow and Velox Vectors are columnar layouts whose goal is to symbolize batches of information in reminiscence. A column is normally composed of a sequential buffer the place row values are saved contiguously and an non-obligatory bitmask to symbolize the nullability/validity of every worth: 

(a) Logical and (b) bodily illustration of an instance dataset.

The Arrow and Velox Vectors codecs already had suitable format representations for scalar fixed-size knowledge varieties (reminiscent of integers, floats, and booleans) and dictionary-encoded knowledge. Nevertheless, there have been incompatibilities in string illustration and container varieties reminiscent of arrays and maps, and an absence of help for fixed and run-length-encoded (RLE) knowledge.

StringView – strings

Arrow’s typical string illustration makes use of the variable-sized element layout, which consists of 1 contiguous buffer containing the string contents (the information), and one buffer marking the place every string begins (the offsets). The scale of a string i could be obtained by subtracting offsets[i+1] by offsets[i]. That is equal to representing strings as an array of characters: 

Arrow authentic string illustration.

Whereas Arrow’s illustration stands out in simplicity, we discovered via a collection of experiments that the next alternate string illustration (which is now known as StringView) gives compelling properties which can be necessary for environment friendly string processing: 

New StringView illustration in Arrow 15.

Within the new representation, the primary 4 bytes of the view object all the time comprise the string dimension. If the string is brief (as much as 12 characters), the contents are saved inline within the view construction. In any other case, a prefix of the string is saved within the subsequent 4 bytes, adopted by the buffer ID (StringViews can comprise a number of knowledge buffers) and the offset in that knowledge buffer.

The advantages of this format are:

  1. Small strings of as much as 12 bytes are absolutely inlined throughout the views buffer and could be learn with out dereferencing the information buffer. This will increase reminiscence locality as the everyday cache miss of accessing the information buffer is prevented, growing efficiency.
  2. Since StringViews retailer a small (4 bytes) prefix with the view object, string comparisons can fail-fast and, in lots of circumstances, keep away from accessing the information buffer. This property hurries up widespread operations reminiscent of extremely selective filters and sorting.
  3. StringView provides builders extra flexibility on how string knowledge is specified by reminiscence. For instance, it permits for sure widespread string operations, reminiscent of 𝑡𝑟𝑖𝑚() and 𝑠𝑢𝑏𝑠𝑡𝑟(), to be executed zero-copy by solely updating the view object.
  4. Since StringView’s view object has a hard and fast dimension (16 bytes), StringViews could be written out of order (e.g., first writing StringView at place 2, then 0 and 1). 

Apart from these properties, now we have discovered that different trendy processing engines and libraries like Umbra and DuckDB observe an identical string illustration strategy, and, consequently, additionally used to deviate from Arrow. In Arrow 15, StringView has been added as a supported format and may now be used to effectively switch string batches throughout these techniques.

ListView – variable-sized containers

Variable-size containers like arrays and maps are represented in Arrow utilizing one buffer containing the flattened parts from all rows, and one offsets buffer marking the place the container on every row begins, much like the unique string illustration. The variety of parts a container on row i shops could be obtained by subtracting offsets[i+1] by offsets[i]: 

Arrow authentic record illustration.

To effectively help execution of vectorized conditionals (e.g., IF and SWITCH operations), the Velox Vectors format has to permit builders to put in writing columns out of order. Because of this builders can, for instance, first write all even row data then all odd row data with out having to reorganize parts which have already been written.

Primitive varieties can all the time be written out of order because the component dimension is fixed and identified beforehand. Likewise, strings will also be written out of order utilizing StringView as a result of the string metadata objects have a relentless dimension (16 bytes), and string contents don’t should be written contiguously. To extend flexibility and help out-of-order writes for the remaining variable-sized varieties in Velox, we determined to maintain each lengths and offsets buffers:

New ListView illustration in Arrow 15.

To bridge the hole, a brand new format referred to as ListView has been added to Arrow 15. It permits the illustration of variable-sized parts which have each lengths and offsets buffers.

Past permitting for environment friendly execution of conditionals, ListView provides builders extra flexibility to slice and rearrange containers (e.g., operations like slice() and trim_array() could be carried out zero-copy), aside from permitting for containers with overlapping ranges of parts.

REE – extra encodings

Now we have additionally added two extra encoding codecs generally present in knowledge warehouse workloads into Velox: fixed encoding, to symbolize that every one values in a column are the identical, usually used to symbolize literals and partition keys; and RLE, to compactly symbolize consecutive runs of the identical component.

Upon dialogue with the group, it was determined so as to add the REE format to Arrow. The REE format is a slight variation of RLE that, as an alternative of storing the lengths of every run, shops the offset through which every run ends, offering higher random-access help. With REEs it is usually potential to symbolize fixed encoded values by encoding them as a single run whose dimension is the complete batch.

Composability is the way forward for knowledge administration

Converging Arrow and Velox’s reminiscence format is a vital step in the direction of making knowledge administration techniques extra composable. It permits techniques to mix the facility of Velox’s state-of-the-art execution with the widespread business adoption of Arrow’s customary, leading to a extra environment friendly and seamless cooperation. The brand new extensions are already seeing adoption in libraries like PyArrow and Polars and inside Meta. Sooner or later, it is going to enable extra environment friendly interaction between initiatives like Apache Gluten (which makes use of Velox internally) and PySpark (which consumes Arrow), for instance.

We envision that fragmentation and duplication of labor could be diminished by decomposing knowledge techniques into reusable parts that are open supply and constructed based mostly on open requirements and APIs. Finally, we hope this work will assist present the muse required to speed up the tempo of innovation in knowledge administration.


This format alignment was solely potential because of a broad collaboration throughout completely different teams. A particular thanks to Masha Basmanova, Orri Erling, Xiaoxuan Meng, Krishna Pai, Jimmy Lu, Kevin Wilfong, Laith Sakka, Wei He, Bikramjeet Vig, and Sridhar Anumandla from the Velox workforce at Meta; Felipe Carvalho, Ben Kietzman, Jacob Wujciak-Jens, Srikanth Nadukudy, Wes McKinney, and Keith Kraus from Voltron Knowledge; and the complete Apache Arrow group for the insightful discussions, suggestions, and receptivity to new concepts.