<!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>
      <journal-title-group>
        <journal-title>PhD Workshop, August</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>A Hardware-Oblivious Optimizer for Data Stream Processing</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Technische Universita ̈ t Ilmenau Ilmenau</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2017</year>
      </pub-date>
      <volume>28</volume>
      <issue>2017</issue>
      <abstract>
        <p>High throughput and low latency are key requirements for data stream processing. This is achieved typically through di erent optimizations on software and hardware level, like multithreading and distributed computing. While any concept can be applied to particular systems, their impact on performance and their con guration can di er greatly depending on underlying hardware. Our goal is an optimizer for a stream processing engine (SPE) that can improve performance based on given hardware and query operators, supporting UDFs. In this paper, we consider di erent forms of parallelism and show measurements exemplarily with our SPE PipeFabric. We use a multicore and a manycore processor with Intel's AVX/ AVX512 instruction set, leading to performance improvements through vectorization when some adaptations like microbatching are taken into account. In addition, the increased number of cores on a manycore CPU allows an intense exploitation of multithreading e ects.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. INTRODUCTION</title>
      <p>Technological advancement leads to more and more
opportunities to increase application performance. For stream
processing, data arrives continuously at di erent rates and
from di erent sources. A stream processing engine (SPE)
has to execute queries fast enough that no data is lost and
results are gathered before the information is already
outdated. A solution to achieve this is a combination of software
optimizations paired with modern hardware for maximizing
parallelism. It is di cult to nd an optimal parametrization
though, e.g. for the number of threads or load balancing
between them. It gets even worse when di erent hardware
properties come into play, like memory hierarchies or CPU
core count.</p>
      <p>For this paper, we consider di erent aspects and
paradigms of parallelization that are applicable on data stream
processing. In addition, rst measurements on SIMD and
multithreading realized on an Intel Core i7 and Intel Xeon
Phi Knights Landing (KNL) with our SPE PipeFabric are
shown. Our nal goal is a full optimizer on a SPE capable
of dealing with unknown UDFs in queries as well as with
arbitrary hardware the system uses. Two consequential tasks
arise from this.</p>
      <p>Exploitation of opportunities given by modern
hardware, like wider CPU registers on Intel's AVX-512
instruction set, manycore processors with 60+ cores on
a chip or increased memory size.</p>
      <p>Analysis of performance impacts by possible UDFs and
operations, like computational e ort or possible
parallelization degree in case of data dependencies.</p>
      <p>The rest of this paper is organized as follows: Next
Section 2 is a short recapitulation about stream processing,
possible parallelism and opportunities given by hardware.
Section 3 summarizes related work done on SIMD
parallelism, hardware-oblivious operations and stream
partitioning in context of data stream processing. Our results are
presented in Section 4, followed by Section 5 with future
work. Section 6 with conclusions tops o this work.
2.</p>
    </sec>
    <sec id="sec-2">
      <title>PREREQUISITES</title>
      <p>This section shortly summarizes requirements on stream
processing and parallelization opportunities in addition to
information on used hardware, like supported instruction
sets.
2.1</p>
    </sec>
    <sec id="sec-3">
      <title>Data Stream Processing</title>
      <p>As already mentioned, high throughput and low latency
are main requirements for stream processing. A data stream
delivers continuously one tuple of data after another,
possibly never ending. Queries on data streams have to consider
that tuples can arrive at alternating rates and they get
outdated after a while, because storing all of them is impossible.
Operating with windows of certain sizes are a common
solution for this property.</p>
      <p>As a consequence, a query has to be processed fast enough
to produce no outdated results as well as keeping up with
eventually fast tuple arrival rates. Handling multiple tuples
at once through partitioning of data or operators exploiting
parallelism possibilities is therefore a must.
2.2</p>
    </sec>
    <sec id="sec-4">
      <title>Parallelism Paradigms</title>
      <p>There are mainly three forms of parallelism on stream
processing that can be exploited.</p>
      <p>Partitioning. Partitioning can be used to increase speedup
through splitting data on di erent instances of the same
operator. Therefore every instance executed in parallel has to
add its function on a fraction of data, increasing throughput
of a query. However, additional costs for assigning data to
instances and merging results afterwards arise, in uencing
the optimal partitioning degree.</p>
      <p>Task-Parallelization. Operators of a query can execute
in parallel if data dependencies allow such parallelism. A
pipelining schema provides possibilities to achieve this,
realized by scheduling mechanisms.</p>
      <p>Vectorization. A single instruction can be applied on
multiple data elements, called SIMD. For stream processing,
some preparatory work is necessary to use this form of
parallelism, like storing a number of tuples before processing
them at once with SIMD support. On the one hand, it
increases the throughput of a query while on the other hand
batching up tuples worsens latency.</p>
      <p>We focus on partitioning and vectorization, because
taskparallelism is mainly a scheduling problem that is not of
further interest at this point.
2.2.1</p>
      <sec id="sec-4-1">
        <title>Partitioning</title>
        <p>
          A speedup through partitioning is achieved mainly with
multithreading. Each partition that contains operators
processing incoming tuples uses a thread, which leads to
challenges on synchronization or load balancing, especially on
manycores, as shown by Yu et al. [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ] for concurrency
control mechanisms. Partitioning is a key for high performance
when using a manycore processor, which provides support
for 200+ threads at the cost of low clock speed. To
investigate the right partitioning degree between reduced load on
each partition and increased overhead from threads as well
as an appropriate function for forwarding tuples to
partitions additional observations have to be made. Statistics
are a common solution, but can be far away from optimal
performance in worst cases.
2.2.2
        </p>
      </sec>
      <sec id="sec-4-2">
        <title>Vectorization</title>
        <p>To use vectorization, certain requirements must be
fullled. Without batching up tuples it is impossible to
apply a vector function on a certain attribute. This leads to
the next challenge, the cache-friendly formation of a batch.
Without careful reordering, any vectorization speedup is lost
through expensive scattered memory accesses. A possible
solution for this is provided by gather and scatter
instructions that index through masking certain memory addresses
for faster access. Additional requirements on vectorization
arise through the used operator function and data
dependencies between tuples. The function must be supported by
used instruction set, while dependencies are solved through
rearrangements or even fundamental changes on the
function of the operator.</p>
        <p>Figure 1 shows the processing model of a query with
batching. Tuples arrive one at a time on the data stream, being</p>
        <p>Tuple T
&lt;A1...An&gt;</p>
        <p>Batch</p>
        <p>Batch B
&lt;T1.A1...Tm.A1&gt;</p>
        <p>...
&lt;T1.An...Tm.An&gt;</p>
        <p>Op
. . .
gathered rst on a batching operator with attribute
grouping in memory realized by vectors until batch size is reached
and then forwarded to the next operator.
2.3</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Hardware Opportunities</title>
      <p>There are mainly two di erent ways to increase
computational speed on hardware, distributed and parallel
computing. Distributed computing uses usually many high-end
processors connected to each other, sharing computational
work between them. The disadvantage comes with
communication costs. With requirements of low latency, we focus
on parallel computing. Manycore processors like the Xeon
Phi series from Intel use simpler cores, but many of them
inside their CPU. This eliminates most of the communication
costs, improving latency while providing wide parallelization
opportunities compared to a single multicore processor.</p>
      <p>The latest Xeon Phi KNL uses up to 72 cores with 4
threads each, available through hyperthreading. In
addition, the AVX-512 instruction set can be used for 512bit
wide operations (SIMD). This leads to great possibilities on
partitioning and vectorization to reduce latency of a query.
There are more interesting improvements on KNL like
clustering modes, huge page support or high-bandwidth memory
on chip (MCDRAM) which we will address in future work.
3.</p>
    </sec>
    <sec id="sec-6">
      <title>RELATED WORK</title>
      <p>For parallelism through vectorization and partitioning on
data streams, a lot of research has been done already,
especially since manycore processors are getting more and more
common. To achieve performance bene ts, those manycore
CPUs rely massively on SIMD parallelism and
multithreading for speeding up execution time.</p>
      <p>For data stream processing, the functionality of operations
like joins or aggregations to give an example, are basically
the same. However, for realization the stream processing
properties have to be taken into account.</p>
      <p>
        Polychroniou et al. [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] take a shot on di erent database
operators, implementing and testing vectorized approaches
for each one. Results show a performance gain up to a
magnitude higher than attempts without SIMD optimization. In
addition to this, their summary of related work gives a good
review about research done with SIMD on general database
operations.
      </p>
      <p>
        For stream partitioning, the degree in terms of numbers of
partitions as well as the strategy like the used split function
for data tuples are the main focus of research. Gedik et al.
[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] visited elastic scaling on stream processing where
parallelization degree on partitioning is dynamically adjusted on
runtime, even for stateful operations. They reviewed
typical problems when auto-parallelization is used like in most
of other approaches.
      </p>
      <p>
        For an optimizer that is hardware-oblivious, additional
points must be considered. Hardware-oblivious means, that
the optimizer is able to maximize performance on any
hardware used, e.g a multicore or a manycore processor. Heimel
et al. [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] implemented an extension for MonetDB called
Ocelot, which is a proof of concept for hardware-oblivious
database operators. They show that such operators can
compete with hand-tuned operators that are tted exactly
for used processing units, like CPUs and GPUs. Teubner et
al. [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] attended to the same topic before, looking deeper into
hardware-conscious and hardware-oblivious hash joins.
      </p>
    </sec>
    <sec id="sec-7">
      <title>EXPERIMENTS</title>
      <p>With our experiments, we want to show the grade of
impact on vectorization and multithreading for data stream
processing. We therefore use two di erent processors, an
Intel Core i7-2600 multicore CPU as well as an Intel Xeon
Phi KNL 7210. As already mentioned before, KNL
supports AVX-512 with 512bit register size and 256 threads, in
contrast to i7s AVX with 256bit and 8 threads.
4.1</p>
    </sec>
    <sec id="sec-8">
      <title>Preliminary Measurements</title>
      <p>First measurements in Table 1 show needed runtime for
corresponding CPUs when vectorization is enabled or
disabled. Therefore an array with 64*1024*1024 elements is
traversed, applying an addition operator (using 32bit
precision) or square root operator (using 64bit precision) on each
of the elements.</p>
      <p>With vectorization, the speedup gain ideally corresponds
directly with the number of elements processed at once, e.g.
when using 32bit integers and the register size is 512bit, 16
elements are processed with one operator execution, leading
to an expected 1/16th of runtime. However, this is not the
case, because these elements needed to be accessed in
memory (ideally in cache). With increased complexity (in terms
of CPU cycles) this accessing costs are reduced compared to
operators costs, as it can be seen in Table 1 with simple
addition and complex square root. When computing the root,
vectorization e ectively doubles the execution speed on i7
processor and even more on KNL. On KNL, the registers
can hold up to 8 64bit oating point numbers, resulting in
around eight times faster execution on square root. On
addition, however, even with prefetching mechanism it is not
possible to pull data fast enough into the registers, because
a simple addition just uses one CPU cycle. Therefore the
full speedup cannot be achieved.</p>
      <p>Results on square root on i7 processor can be explained
through underlying hardware. Ideally, with AVX, 256bit
registers and 64bit numbers, the speedup should result in</p>
      <sec id="sec-8-1">
        <title>Processor i7-2600 KNL 7210</title>
      </sec>
      <sec id="sec-8-2">
        <title>Vectorization</title>
        <p>disabled
enabled
disabled
enabled</p>
        <p>Addition
42ms
30ms
98ms
40ms</p>
        <p>Square Root
187ms
92ms
998ms
129ms
around four times faster execution, however, it is only
doubled. Further research points to how 256bit register are
realized on i7-2600 (Sandy Bridge) - as processor of the rst
generation of AVX instruction set, it still uses two 128bit
registers combined to achieve 256bit width. On performance
there is only a small bene t of using 256bit loads and stores
compared to 128bit, leading to only doubled speedup.
4.2</p>
      </sec>
    </sec>
    <sec id="sec-9">
      <title>SPE Tests</title>
      <p>Our SPE PipeFabric is a framework for data stream
processing, written in C++. The data streams as source of
tuples can be constructed for example through network
protocols. A query consists out of di erent stream processing
operators that combined are forming a data ow graph. It
supports selections, projections, aggregates, groupings, joins
and table operations, as well as complex event processing.
The focus of the framework lies on low latency, realized
through e cient C++ template programming.</p>
      <p>For the tests, the data stream produces tuples through
a generator. Increasing the number of attributes or using
di erent data types just add a constant delay for each
tuple, increasing runtime without changing the curves
significantly. Therefore only a single integer as an attribute is
counted up. In Figure 2, the needed time to produce a
certain amount of tuples (up to 109) is measured (note the
logarithmic scale of y-axis). With low number of produced
tuples, the overhead through thread generation worsens
execution time. This changes very quick, providing an intense
speedup. When generation is singlethreaded, KNL performs
worse than i7-2600 caused by slower clock speed. But when
cores are fully utilized, running maximum number of threads
through OpenMP, KNL can outperform the multicore CPU
easily.</p>
      <p>Figure 3 shows speedup achieved on i7-2600 and KNL
on queries with vectorization. Therefore tuples are batched
rst with di erent batch sizes on each run, followed by an
aggregation operator which applies a simple addition or a
complex square root on single attributes. These
aggregations are performed with and without vectorization, the
difference on runtime results directly into speedup, e.g. when
runtime is halved, the speedup is 100%.</p>
      <p>Taking a further look on Figure 3 reveals that speedup
increases with batch size. This is relatively obvious, because
with more tuples that can be processed at once by increased
throughput, runtime of the query gets lower. However, this
comes with the cost of latency, because results are delayed
until a batch is full. An additional observation between
addition and square root as aggregation operator can be
made. With addition function, the performance gain is
relatively low. This is because accessing the batch in cache
takes longer than applying vectorized addition on it, even
with prefetching mechanism. With square root, the
operation takes signi cantly longer (in CPU cycles), so it is not
limited that much by memory access on cache anymore.</p>
    </sec>
    <sec id="sec-10">
      <title>RESEARCH PLAN</title>
      <p>
        Vectorization and partitioning are the main two strategies
which provide the most performance gain when set up
accordingly to stream and query properties. Regarding
vectorization, a batching mechanism is needed to exploit the full
parallelism of wider CPU registers. With increased batch
size, results of the query are delayed leading to increased
latency but higher throughput. For partitioning, too many
or too few partitions apart from optimum can even worsen
the query execution time, same with uneven load
balancing between partitions as shown by Fang et al. [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. It is
all a matter of right parametrization, depending on query,
operators and underlying hardware.
      </p>
      <p>This leads to our future work, where we will analyze
impact on performance for certain strategies to nally come to
an hardware-oblivious optimizer for queries on data stream
processing, capable of dealing with UDFs as well as with
di erent hardware sets. In di erence to hardware-conscious
optimizers which deliver only good precision for
optimizations on certain hardware, our optimizer should generally
being able to adapt its strategy on any given modern
hardware.</p>
      <p>However, it is a tradeo between speedup and latency,
greatly in uenced by hardware used. We focus on
parallelization on multicore and manycore CPUs, especially
the latter one, because it is the most promising
architecture for performance increasements with given requirements.
With technical advancement additional chances are given,
e.g. memory on package with high bandwidth, called
MCDRAM on the latest manycore Xeon Phi KNL processor.
When UDF support is realized, it is necessary to investigate
key parameters for optimization, e.g. complexity of used
function and data dependency.
6.</p>
    </sec>
    <sec id="sec-11">
      <title>CONCLUSION</title>
      <p>For data stream processing, high throughput in terms of
being able to process as many data as possible at the same
time as well as low latency with fast responses on queries are
main requirements. Exploiting parallelism is the answer,
which is possible at di erent levels and degrees. In this
paper, we show in uence of parallelism on instruction level
with vectorization as well as multithreading with our SPE
PipeFabric and compare rst results between multicore and
manycore CPU.</p>
      <p>SIMD e ects improve performance when data is stored
in a cache-friendly way within contiguous memory. For
stream processing, each tuple cannot be processed one after
another, therefore a batching mechanism is needed. This
batching has to take care of storing data carefully for SIMD
processing. Increased register width of Intel's Xeon Phi
KNL with AVX-512 support leads to signi cant performance
gains when not blocked by slow memory accesses. On the
one hand, the computational workload must be high enough
to surpass memory or cache accesses. This is not the case
when additions on an aggregation operator are performed,
as we showed in our experiments. On the other hand, with
increased complexity SIMD operations are di cult to realize
and must be supported by used instruction set.</p>
      <p>Multithreading is another important factor when it comes
to a manycore processor. Slow clock speed leads to poor
singlethreaded performance compared to a multicore
processor. This disadvantage is negated when enough cores can
be utilized and parallelism is maximized. However,
communication between threads, memory accesses and scheduling
from threads to cores are no trivial tasks for optimizing
performance, therefore more measurements are needed to prove
results.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>J.</given-names>
            <surname>Fang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T. Z.</given-names>
            <surname>Fu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Zhou</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Zhu</surname>
          </string-name>
          .
          <source>Parallel Stream Processing Against Workload Skewness and Variance. CoRR</source>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>B.</given-names>
            <surname>Gedik</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Schneider</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Hirzel</surname>
          </string-name>
          , and
          <string-name>
            <surname>K.-L. Wu</surname>
          </string-name>
          .
          <article-title>Elastic Scaling for Data Stream Processing</article-title>
          . IEEE'
          <volume>14</volume>
          , pages
          <fpage>1447</fpage>
          {
          <fpage>1463</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M.</given-names>
            <surname>Heimel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Saecker</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Pirk</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Manegold</surname>
          </string-name>
          , and
          <string-name>
            <given-names>V.</given-names>
            <surname>Markl</surname>
          </string-name>
          .
          <article-title>Hardware-oblivious Parallelism for In-memory Column-stores</article-title>
          .
          <source>VLDB</source>
          , pages
          <volume>709</volume>
          {
          <fpage>720</fpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>O.</given-names>
            <surname>Polychroniou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Raghavan</surname>
          </string-name>
          , and
          <string-name>
            <given-names>K. A.</given-names>
            <surname>Ross. Rethinking SIMD</surname>
          </string-name>
          <article-title>Vectorization for In-Memory Databases</article-title>
          . SIGMOD, pages
          <volume>1493</volume>
          {
          <fpage>1508</fpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Teubner</surname>
          </string-name>
          , G. Alonso,
          <string-name>
            <given-names>C.</given-names>
            <surname>Balkesen</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M. T.</given-names>
            <surname>Ozsu</surname>
          </string-name>
          .
          <article-title>Main-memory Hash Joins on Multi-core CPUs: Tuning to the Underlying Hardware</article-title>
          . ICDE, pages
          <volume>362</volume>
          {
          <fpage>373</fpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>X.</given-names>
            <surname>Yu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Bezerra</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Pavlo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Devadas</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Stonebraker</surname>
          </string-name>
          .
          <article-title>Staring into the Abyss: An Evaluation of Concurrency Control with One Thousand Cores</article-title>
          . VLDB, pages
          <volume>209</volume>
          {
          <fpage>220</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>