<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Homoiconicity For End-to-end Machine Learning with BOSS</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Hubert Mohr-Daurat</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Holger Pirk</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Imperial College London</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>BICOD'21: British International Conference on Databases</institution>
          ,
          <addr-line>Mars 28</addr-line>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Database Management Systems (DBMS)</institution>
          ,
          <addr-line>where the</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>It is common for machine learning applications to have complex operator pipelines, with several steps before and after the main execution of the core machine learning algorithm. Consequently, data movement between processes has a performance cost for the execution of the application. In this paper, we propose an end-to-end machine learning framework based on the principle of homoiconicity: data and code are represented in a single unified syntax. This approach allows the eficient interpretation of custom operators at the core of a relational database system. We also present the implementation of a data cleaning framework as an initial milestone. This work is a part of a larger research project to implement BOSS, a novel, general-purpose relational database system that stores and processes homoiconic data. relational database, homoiconicity, symbolic expressions, machine learning, data cleaning, data imputation</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <sec id="sec-1-1">
        <title>The core part of any machine learning (ML) pipeline is</title>
        <p>the model to be learned during training and executed
during inference. It is, thus, not surprising that this is
the most extensively researched and optimized aspect of
ML applications.</p>
        <p>However, the model training and inference is not the
only component of the data processing pipeline that plays
a role in the application’s overall performance. Many
applications move large amounts of data as inputs and
produce large output datasets. This data movement is
costly and, often, principally unnecessary.</p>
        <p>In addition, many applications perform internal data
movement for various data operations, such as data
augmentation or data normalisation. Some of these steps</p>
      </sec>
      <sec id="sec-1-2">
        <title>The complexity of such pipelines with multiple layers</title>
        <p>increases not only the overhead for data movement but
nance of the logic to connect them.</p>
        <p>Data cleaning is a particularly interesting example of
such data movement-intensive components in the case
cause the model learning and the inference process are
extremely sensitive to the data quality. Input data is
puting missing values and searching and fixing incorrect
values (based on common sense, expert knowledge, and
user-defined constraints). Algorithms for these tasks</p>
      </sec>
      <sec id="sec-1-3">
        <title>The DBMS is a natural starting point for such a central</title>
        <p>system. DBMS are designed to store, retrieve and
proinvolve the usage of dedicated libraries and even systems. the data movement overhead out of the DBMS. With
also the engineering cost of implementation and mainte- and can still be significant for large-scale data movement.
of an ML pipeline. Cleaning the data is necessary be- retrieval and transformation steps in the same process or
therefore generally cleaned using methods such as im- eliminated due to the additional transformations needed
cess a large amount of data eficiently, taking advantage
of strategies and technologies studied, developed and
improved over several decades. P A R T I T I O N I N G</p>
        <p>However, implementing all the desired features in the
DBMS requires new data representations, operators and
logic, which are not standard in typical DBMS. This is
challenging to implement while preserving the advan- int + +
tages of the DBMS (such as the query optimizer). int int symbol x
wfuinItmhctpiaolentmrsae(dUnetD-ionFf.gs)tIhimsespdtlreeasmiigreehndttffioenragwtuatrhredesmbinuatashdauasstaeabrh-adsigeehfinceoodmveers- batch 1 .1. batch 2 .1. 2.. batch 3 A.. i.n2.t f1lo...a5t
head and prevents query optimizations; implementing C O L U M N S T O R A G E
them at the core of the DBMS backend is more eficient
but requires significant efort and expert knowledge. Figure 1: shape-wise partitioning mechanism and storage</p>
        <p>Instead, we propose implementing a more generic ex- representation example.
tensible system that is flexible and takes advantage of the
DBMS eficiency to manipulate data. To achieve that, the
DBMS stores as data the executable code that extends • ease for the user to implement new ML algorithms
the DBMS functionality. Storing the code as data means and tools by assembling them from operators
that the code is an integral part of the relational repre- using symbolic expression logic with flexibility
sentation and can be manipulated by the DBMS kernel. while keeping native performance
This method is fundamentally diferent from UDFs and
triggers, which exist only in the schema and are be re- • with the logic as data paradigm, the approach
trieved and run as a black box at query time. With our opens new possibilities for optimizations, unified
approach, the DBMS handles this custom logic eficiently, for both the data (as usually handled by the query
taking advantage of the optimization strategies produced optimizer) and for the logic (as usually handled by
by DBMS research. the compiler) by exposing the logic as symbolic</p>
        <p>
          Fundamentally, homoiconicity refers to this idea that data to the database at every level, from query
code can be read, modified and stored like data. The plan to storage layers.
practically most common forms of homoiconic data are
symbolic expressions (s-expressions). An s-expression is • symbolic expressions are not used only to express
represented as a (potentially nested) list and can, there- the logic of the queries. They are also stored in the
fore, be modified as well as evaluated. For example, ’1 database and evaluated eficiently at query time,
+ 2’ would be represented by the list ’(Plus 1 2)’. Lisp- whose benefits and implementation are detailed
like languages use s-expressions to represent all code as in the use case in the next section.
s-expressions and allow Turing-complete programming
[
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. They even allow the representation of unknown
or undefined values in the form of ”Symbols”. Unfor- 2. Storing and Processing
tunately, lisp implementations are ill-suited to support
data-intensive applications due to prohibitively high in- Homoiconic Data
terpretation overhead (see Section 4).
        </p>
        <p>Inspired by these homoiconic languages, we are
implementing a DBMS called BOSS for Bulk-Oriented
SymbolStore. This database stores symbolic expressions in the
form of symbols and complex expressions. However, in
our implementation, the evaluation of the expressions is
performed for a large batch of data at once, thus
amortizing interpretation overhead.</p>
        <p>Applied to the ML domain, native operators are
implemented in the database only for the basic blocks of the
ML operations (e.g. transformations, activations). Only
the logic of the ML algorithm, less generic, is left to be
implemented in userspace with symbolic expressions.</p>
        <p>The benefits of this approach are:</p>
      </sec>
      <sec id="sec-1-4">
        <title>As data cleaning is a data-intensive task, we, naturally,</title>
        <p>
          selected the decomposed storage model (DSM) [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] to
represent (plain) relational data. On top of DSM data, we
implemented the BOSS kernel following the X100-model[
          <xref ref-type="bibr" rid="ref4">4</xref>
          ]:
BOSS’ query processor partitions data into micro-batches
to keep intermediate results cache-resident. In addition
to plain relational data, however, BOSS needs to process
homoiconic expressions that represent computation
efifciently. Interpreting such expressions usually incurs
significant overhead.
        </p>
        <p>To amortize this overhead, we developed a novel
technique called shape-wise partitioning &amp; decomposition as
shown in Figure 1. First, collections of expressions are
(horizontally) partitioned by shape, i.e., all expressions
(ittcrnhiotetaimceotugnpore.onsrislsSvye,eedwcdlyoifhfe)onirdrldemei,ncbt.ohtamhIetncepchiroFo2sibmgeasudpst,reooetrnhtey1eusp,nseeetsxs.atgpoor.r,grfeiubntsahmsgtiecoebhnneaxtss1septfrhsdoetaarosttmsraaieodisanndppsatalaawrdir-enoe- 110010i()rsyTeeuQmm00100.0001000.11010000 i()rsyTeeuQmm1010.00010.111000
iinntteeggeerrss aanndd abdadtcthh3emstotoreastehxirpdr.esAssiosnhsatphea-twmisuelptiaprltyittiwono- 0.S0F01 .0010 .100 .01 1 2 5 01 .0100 .100 .01 1 2 5 01 B0u.0lk0B1OSS IHmypAuIteDB
ing ensures homogeneous partitions, entire partitions Q1 Q6 Wolfram
can be processed with a minimal number of function
calls (one per subexpression). This ensures highly CPU- Figure 2: Performance comparison tests for TPC-H Q1/Q6
eficient processing. (relational), and HyAI (imputation). The missing bars for
Wolfram are caused by the engine running out of memory.</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>3. Use case: data imputation</title>
      <p>to the user and benefits from the optimizations allowed
by the bulk evaluation method.</p>
      <p>We implemented a data imputation framework in the
context of a project called HyAI1. The project’s overall
goal was to optimize the decisions to charge or consume
hydrogen batteries using machine learning technologies 4. Evaluation
that model future electricity consumption from the
analysis of many diferent data sources. Because the batteries All the experiments have run on a PC with an Intel
i9were intended to be deployed in areas where data trans- 10990K CPU and 32GB RAM DDR4 3600MHz.
ferred from these sources might be unreliable, a robust To confirm that relational operators in BOSS are
perimputation framework was implemented in the database forming competitively with state-of-the-art DBMS, we
management system so that the user could define custom compared the performance of BOSS with MonetDB using
and potentially complex imputation logic. the TPC-H queries Q1 and Q6 with various scale factors.</p>
      <p>
        Missing data is commonly handled in database systems The results in Figure 2 shows that BOSS performs on the
by inserting null values and internally defining an arbi- same magnitude with MonetDB without an impact from
trary value as null or using a boolean flag. This method having to support homoiconicity in our implementation.
does not allow to specify why the data is missing and Also shown in Figure 2, we compared the handling of
to let the data cleaning process decide how the value is missing data with another implementation, ImputeDB
imputed. However, there are multiple reasons why data [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], which has similar functionalities. We evaluated a
would be missing. Ideally, the user should be allowed to dataset from HyAI project (50K rows) where 50% of the
specify through code logic the intent and decide how to data is missing at random for five columns. Data is
imhandle missing data. puted by taking a random value from data in the same
      </p>
      <p>One approach for the user to handle missing values column. BOSS performs better with a factor of x261. This
is by calling the imputation method on the fly before in- result shows that the bulk approach to implementing
imserting the data into the database. However, this method putation operators is highly eficient. Our method to
does not allow the use of future data for the imputation. evaluate expressions eficiently could also benefit more
For example, both previous and subsequent values may advanced imputation techniques.
be needed for the interpolation of time series data. In addition, the comparison for both relational
opera</p>
      <p>Alternatively, the user could handle missing values tors and missing data evaluation with another backend
as part of the query logic by detecting the missing val- based on the Wolfram engine shows that our
implementaues and using nested queries or UDFs. However, this tion outperforms by several orders of magnitude the
commethod usually incurs an execution overhead that afects mercial homoiconic engine. It confirms that evaluating
performance and increases the queries’ complexity. homoiconic data comes with a high cost for interpreting</p>
      <p>
        With the imputation framework that we implemented, the expressions, which is solved with the technique we
the user stores missing data as complex expressions. The have implemented in BOSS.
expressions describes the logic to use for the data
imputation, e.g. instead of inserting a ’null’ value, the user
inserts the expression ’(PreviousValue() + NextValue()) 5. Related Work
/ 2’ to do a simple local average. As presented in the
previous section, this approach provides more flexibility
Data cleaning is a critical aspect of many decision-making
and analytics applications, particularly in ML-based
software. Some solutions have been proposed to automate
the process, such as HoloClean [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], an entire system run
1&lt;https://www.h2gopower.com/hyai&gt;
sign, task-specific code can be stored and processed with
the data, thus providing unprecedented extensibility. In
this paper, we have demonstrated the advantages of this
design for handling data imputation.
      </p>
      <p>
        For the future, we plan to extend the system with
additional features for data processing pipelines: operators
to support additional data cleaning use cases, algebraic
operators needed for model training and inference and
even domain-specific operators. The system will, further,
benefit from relational components such as query
optimization, transactional semantics and data visualization.
side-by-side with the DBMS. Alternative solutions have
been proposed to integrate the data cleaning operators
as part of the database query, such as ImputeDB as an
imputation module for the Data Civilizer framework [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
      </p>
      <p>Both approaches do not allow the user to make
decisions during the data cleaning, except for some initial
setup in the case of HoloClean. They difer from our
method, which performs data imputation during query
but is based on the information provided by the user
during data insertion.</p>
      <p>
        Most research on accelerating the ML pipeline and
using a unified data management solution focuses on the
acceleration of the training step. The approach in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]
has similarities with our work. They propose lambda
expressions as generic user-defined operators, which are
more eficient than usual UDFs. However, lambda
expressions are used only in the queries and do not store code
logic in the database. Their focus is primarily on training
and inference and not on data cleaning. Their solution
also difers from ours since they use JIT-compilation to
optimize the evaluation of the expressions.
      </p>
      <p>
        Tupleware [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] also proposes a similar approach for
their general end-to-end analytic solution by analysing
the code of UDFs and taking advantage of JIT compilation
to find the best pipeline strategy when merging the
custom operator code with the query code. The drawback
is a warm-up overhead before the workload execution,
which is negligible for heavy workloads but can be a
problem when a fast response is required [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] (e.g.
visualisation, or high-frequency inference).
      </p>
      <p>
        In addition, there is research work on integrating ML
operators as part of database kernel ([
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ], [13]). This
approach is eficient since ML operators are integrated
deep inside the database implementation but require
investing time to implement ad-hoc code for each needed
operator. Similarly, LMFAO [14] propose to represent
ML operators as aggregate queries. This method allows
interesting optimizations but is limited to operators that
can be represented as aggregates. Some research takes
the opposite approach and implements the relational
operators in a linear algebra kernel [15]. Finally, another
approach uses a unified intermediate language for both
relational and ML operators ([16], [17]).
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M.</given-names>
            <surname>Raasveldt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Mühleisen</surname>
          </string-name>
          ,
          <article-title>Don't hold my data hostage: A case for client protocol redesign (</article-title>
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>J. McCarthy</surname>
          </string-name>
          ,
          <article-title>Recursive functions of symbolic expressions and their computation by machine</article-title>
          ,
          <string-name>
            <surname>Part</surname>
            <given-names>I</given-names>
          </string-name>
          ,
          <source>CACM (April '60).</source>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>P.</given-names>
            <surname>Boncz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. L.</given-names>
            <surname>Kersten</surname>
          </string-name>
          ,
          <article-title>Monet: A next-Generation DBMS Kernel for Query-Intensive Applications</article-title>
          ,
          <source>Ph.D. thesis</source>
          , Universiteit van Amsterdam,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>M.</given-names>
            <surname>Zukowski</surname>
          </string-name>
          , et al.,
          <article-title>Monetdb/x100-a dbms in the cpu cache</article-title>
          .,
          <source>IEEE Data Eng. Bull</source>
          . (
          <year>2005</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Cambronero</surname>
          </string-name>
          , et al.,
          <article-title>Query optimization for dynamic imputation</article-title>
          ,
          <source>PVLDB</source>
          (
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>T.</given-names>
            <surname>Rekatsinas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Chu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I. F.</given-names>
            <surname>Ilyas</surname>
          </string-name>
          , C. Ré,
          <article-title>HoloClean: Holistic data repairs with probabilistic inference</article-title>
          ,
          <source>PVLDB</source>
          (
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>D.</given-names>
            <surname>Deng</surname>
          </string-name>
          , et al.,
          <article-title>The data civilizer system</article-title>
          ,
          <source>in: Cidr</source>
          ,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>M.</given-names>
            <surname>Schüle</surname>
          </string-name>
          , et al.,
          <article-title>In-database machine learning: Gradient descent and tensor algebra for main memory database systems</article-title>
          ,
          <source>BTW</source>
          (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>A.</given-names>
            <surname>Crotty</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Galakatos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Dursun</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Kraska</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Cetintemel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Zdonik</surname>
          </string-name>
          , Tupleware: Redefining Modern Analytics, arXiv:
          <fpage>1406</fpage>
          .6667 (
          <year>2014</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>T.</given-names>
            <surname>Kraska</surname>
          </string-name>
          ,
          <string-name>
            <surname>Northstar:</surname>
          </string-name>
          <article-title>An interactive data science system</article-title>
          ,
          <source>PVLDB</source>
          (
          <year>2018</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>B. De Boe</surname>
          </string-name>
          , et al.,
          <article-title>IntegratedML: Every SQL Developer is a Data Scientist</article-title>
          , in: DEEM@SIGMOD,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>K.</given-names>
            <surname>Karanasos</surname>
          </string-name>
          , et al.,
          <source>Extending Relational Query Processing with ML Inference</source>
          ,
          <string-name>
            <surname>CIDR</surname>
          </string-name>
          (
          <year>2020</year>
          ). 6. Conclusion and Future Work [13]
          <string-name>
            <given-names>J.</given-names>
            <surname>Hellerstein</surname>
          </string-name>
          , , et al.,
          <article-title>The MADlib Analytics Library or MAD Skills, the SQL</article-title>
          , arXiv:
          <fpage>1208</fpage>
          .4165 (
          <year>2012</year>
          ).
          <article-title>Data movement is a significant performance factor for</article-title>
          [14]
          <string-name>
            <given-names>M.</given-names>
            <surname>Schleich</surname>
          </string-name>
          , et al.,
          <string-name>
            <given-names>A Layered</given-names>
            <surname>Aggregate</surname>
          </string-name>
          <article-title>Engine for modern data processing pipelines: the complexity of data Analytics Workloads</article-title>
          , in: SIGMOD, ,
          <year>2019</year>
          .
          <article-title>processing tasks involving steps such as data cleaning</article-title>
          , [15]
          <string-name>
            <given-names>L.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Kumar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Naughton</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. M.</given-names>
            <surname>Patel</surname>
          </string-name>
          ,
          <article-title>Towards normalization, model training and visualization already linear algebra over normalized data</article-title>
          ,
          <source>PVLDB</source>
          (
          <year>2017</year>
          ).
          <article-title>stresses interfaces and will only increase</article-title>
          . To address [16]
          <string-name>
            <given-names>A.</given-names>
            <surname>Shaikhha</surname>
          </string-name>
          , et al.,
          <article-title>Multi-layer optimizations for this problem, we developed a new data processing sys- end-to-end data analytics</article-title>
          ,
          <source>in: CGO@PPoPP</source>
          ,
          <year>2020</year>
          .
          <article-title>tem architecture around the idea of homoiconicity, i</article-title>
          .e., [17]
          <string-name>
            <given-names>S.</given-names>
            <surname>Palkar</surname>
          </string-name>
          , et al.,
          <string-name>
            <surname>Weld</surname>
          </string-name>
          :
          <article-title>A Common Runtime for the uniform representation of data and code</article-title>
          . In this de- High
          <source>Performance Data Analytics</source>
          (
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>