<!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>DejaVu: Recycling Tuning Setups in Hive Query Compilation</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Edson Ramiro Lucas Filho</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Eduardo Cunha de Almeida</string-name>
          <email>eduardog@inf.ufpr.br</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stefanie Scherzinger</string-name>
          <email>stefanie.scherzinger@oth-regensburg.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>OTH Regensburg</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Universidade Federal do Parana ́</institution>
          ,
          <country country="BR">Brazil</country>
        </aff>
      </contrib-group>
      <fpage>118</fpage>
      <lpage>122</lpage>
      <abstract>
        <p>SQL-on-Hadoop processing engines have become state-of-the art, yet the skills required to tune these systems are rare in the job market. Automated tuning advisers can profile the low-level MapReduce jobs and propose appropriate tuning setups, but up-front tuning is time consuming and costly. In this demo, we present DejaVu. DejaVu integrates with Hive and effectively reduces the tuning costs by caching tuning setups for partial query plans: When the SQLon-Hadoop engine Hive compiles SQL queries into physical query plans, single MapReduce jobs tend to be similar between query plans. By recycling the tuning setups for similar low-level MapReduce jobs, DejaVu can effectively cut down the time spent profiling the TPC-H query workload in half, achieving similar impact on the performance of the jobs. While we employ Starfish in this demo, DejaVu can leverage any third-party MapReduce tuning adviser.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Introduction</title>
      <p>
        More than a decade after the publication of the seminal MapReduce paper [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], we can
observe a clear preference among Hadoop or Spark users for higher-level query
languages [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. SQL-on-Hadoop systems compile SQL queries into query plans of
MapReduce jobs. Naturally, this greatly improves the productivity of data scientists. Yet
compiling queries to query plans, and then scheduling its jobs in a cluster is only half the
battle: The underlying MapReduce framework needs to be tuned for performance.
      </p>
      <p>
        The expertise required for allocating the right mix of physical resources and for
twiddling with the tuning knobs is rare. Also, Hive [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] currently implements almost a
1000 tuning parameters, so manual tuning is quite out of the question.
      </p>
      <p>
        Automated tuning advisers for MapReduce frameworks rely on profiling
MapReduce jobs [
        <xref ref-type="bibr" rid="ref2 ref6">6, 2</xref>
        ], at the cost of imposing a runtime overhead. For instance, the Starfish
tuning adviser can cause an overhead of up to 50% [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] during profiling. Thus, when the
query workload is highly dynamic, re-tuning is costly in cloud-based environments.
      </p>
      <p>In this demo, we present DejaVu, a tool that integrates with the SQL-on-Hadoop
engine Hive. Rather than contributing yet another tuning adviser, DejaVu employs
thirdparty tuning advisers like Starfish, but caches tuning setups for partial query plans to
avoid unnecessary job profiling. Our approach relies on two observations regarding the
query plans compiled from SQL queries: (1) The individual MapReduce jobs within a
query plan often have different resource requirements. (2) Since the jobs are generated,
MapReduce jobs tend to be similar across query plans.</p>
      <p>Regarding observation (1), we conclude that each job benefits from having a
customtailored tuning setup, i.e., the configuration of its tuning parameters. In contrast,
uniformly applying a tuning setup to all jobs requires maximum settings, and can be
wasteful. Consequently, we pursue non-uniform tuning and assign one tuning setup per job.</p>
      <p>Let us now consider observation (2). We regard two MapReduce jobs as similar
from the perspective of tuning, if they have the same code signature. Intuitively, the
code signature of a MapReduce job captures the SQL operators implemented by this
job, as well as the expected size of the input. This information is available through
the Hive query compiler. Our hypothesis (which we can confirm in our experiments) is
that jobs that share the same code signature benefit from the same tuning setups. We
therefore may recycle tuning setups for similar jobs, to reduce profiling time.</p>
      <p>Let us consider the TPC-H queries compiled on Hive-0.13, which yields 106
MapReduce jobs3. For 71% of these jobs, there is at least one other job with the same code
signature. Fewer than a third of the jobs have a unique code signature.</p>
      <p>
        This inspires the idea of recycling tuning setups for similar jobs. Over time, we may
even be able to assign tuning setups for ad-hoc queries, which we have not encountered
yet. In fact, ad-hoc queries are prevalent in many query workloads [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], yet tuning
advisers for MapReduce frameworks rely on profiling the complete workload up front. Thus,
our approach can be used in environments where traditionally, tuning advisers fail.
      </p>
      <p>
        As we show shortly, by non-uniform tuning and by recycling tuning setups, we can
effectively reduce profiling costs. Note that earlier, we have reported on a predecessor
tool called Chameleon [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Like DejaVu, Chameleon performs non-uniform tuning. Yet
in Chameleon, tuning setups are only assigned manually to MapReduce jobs. In
contrast, DejaVu delegates job tuning to third-party tuning advisers and is fully automated.
In [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], our full paper presents in greater detail the caching mechanism of DejaVu and
the experimental results.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Caching Code Signatures</title>
      <p>We next introduce code signatures, and the code signature cache as the datastructure at
the heart of DejaVu.</p>
      <p>The SQL-on-Hadoop engine Hive compiles SQL queries into query plans. The
lowlevel MapReduce jobs are annotated by Hive, and annotations are accessible via the
Hive Java API. Each job carries a list of the physical query operators that are
implemented by this job. Further, for each operator, an estimated input cardinality is given.
Example 1. TCP-H query 1 is compiled by Hive 0.13 to a sequence of two MapReduce
jobs. The first job is annotated with the operators Filter, Select, and GroupBy, each with
cardinality 2. The job is further annotated with the operators TableScan, ReduceSink,
and FileSink, each with a cardinality of 1. In our setting (c.f. Section 3), the estimated
input size is 7.24GB.</p>
      <p>We hypothesize that jobs with the same annotations have similar resource
requirements. Therefore, they may be executed with the same tuning setups, even though their
Java code differs. In our experiments, as discussed shortly, we are able to confirm this.
3 Here, we ignore approx. 50 auxiliary jobs that are executed only locally, rather than as a</p>
      <p>MapReduce job, so they do not require a MapReduce tuning setup.</p>
      <p>
        We capture the annotations by the code signature, a tuple stating the input size
(given in order of magnitude), and the annotated query operators with their cardinalities.
Example 2. We continue with TPC-H query 1. The code signature of the first job is
h9; FileSink : 1; Filter : 1; GroupBy : 2; ReduceSink : 1; Select : 2; TableScan : 1i
We have implemented the code signature cache in Java, and integrated it with Apache
Hive 0.13. We leverage tuning setups generated by the Starfish tuning adviser [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. We
run Starfish with sampling turned off (i.e., profiling all MapReduce jobs completely), to
obtain high-quality tuning profiles. Using Starfish 0.3.04, we are tied to Hadoop 0.20.2.
We evaluate the TPC-H queries rewritten in HiveQL5. The data has been generated with
a scale factor of 10, which amounts to 10.46GB of data stored on disk.
      </p>
      <p>Our experiments were executed in a cluster with three physical machines. We isolate
the master node on one machine, so that it does not influence the profiling of worker
jobs. In particular, each machine has a Intel(R) Core(TM) i3-3240 CPU @ 3.40GHz,
4GB of RAM, 1TB of disk. All our profiling runs are configured with the out-of-the-box
tuning setup that we refer to as “Hadoop Standard”.
4 https://www.cs.duke.edu/starfish/release.html, last accessed September 2019.
5 https://issues.apache.org/jira/browse/HIVE-600
job causes a cache miss in the code signature cache
job causes a cache hit in the code signature cache
Recurring code signatures. We have compiled the TPC-H queries on Hive 0.13. There
is a considerable share of recurring code signatures, with 24 code signatures shared by
70% of the 106 MapReduce jobs.</p>
      <p>We profile the 22 TPC-H queries in the order of the TPC-H benchmark specification.
Figure 2 shows the profiling time per query. In total, over ten thousand seconds are spent
on profiling. In Figure 2 We visually distinguish two groups of jobs:
1. Jobs which cause a cache miss in the code signature cache,
2. and jobs which cause a cache hit in the code signature cache.</p>
      <p>We can observe that for the first TPC-H query, all jobs would cause a cache miss. Yet
already for the second and third queries, we’d have cache hits, even though the savings
are minor. With the code signature cache becoming more populated, we get more cache
hits, and in some cases, some substantial savings in the profiling time. For instance, for
queries Q6 and Q14, we can recycle all tuning setups from the cache. Thus, they require
no profiling at all.</p>
      <p>
        You may find more details about the caching mechanism and other results in our
full paper [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
4
      </p>
    </sec>
    <sec id="sec-3">
      <title>Demo Outline</title>
      <p>To make the internals of DejaVu transparent in our demo, we have built a web interface,
as shown in Figure 3:
– In the upper left, we can choose among the TCP-H queries and inspect their code.
– Upon the push of a button, we have Hive compile a query into a query plan and
submit it to be executed by Hadoop, as shown in the left.
– The queries will have their jobs profiled in the case of a cache miss. In the case of
a cache hit, the job will receive new tuning setup (generated by Starfish).
– To the right, our interface visualizes the contents of the code signature cache. We
can see how the cache is getting populated over time.
– Also, to the right we can see the rank of run times and observe the benefits of the
tuning cache.</p>
      <p>The web-based GUI is for demonstration purposes only. At this point, DejaVu is
fully operational and integrated with Hive. Visitors will be able to interact with DejaVu.</p>
      <p>Acknowledgments We thank Herodotos Herodotou for all the support with Starfish.
This study was financed in part by the Coordenac¸a˜o de Aperfeic¸oamento de Pessoal de
N´ıvel Superior - Brasil (CAPES) - Finance Code 001.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Dean</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ghemawat</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <source>MapReduce: Simplified Data Processing on Large Clusters. In: OSDI</source>
          (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Duan</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Thummala</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Babu</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Tuning Database Configuration Parameters with iTuned</article-title>
          .
          <source>ReCALL</source>
          <volume>2</volume>
          (
          <issue>1</issue>
          ),
          <fpage>1246</fpage>
          -
          <lpage>1257</lpage>
          (aug
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Filho</surname>
            ,
            <given-names>E.R.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>de Almeida</surname>
            ,
            <given-names>E.C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Scherzinger</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <string-name>
            <surname>Don't Tune</surname>
          </string-name>
          <article-title>Twice: Reusing Tuning Setups for SQL-on-Hadoop Queries</article-title>
          .
          <source>In: ER 2019 - 38th International Conference on Conceptual Modeling</source>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Filho</surname>
            ,
            <given-names>E.R.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Picoli</surname>
            ,
            <given-names>I.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>de Almeida</surname>
            ,
            <given-names>E.C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Le Traon</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          :
          <article-title>Chameleon: The Performance Tuning Tool for MapReduce Query Processing Systems</article-title>
          .
          <source>In: 29th SBBD - Demos and Applications Session - ISSN 2316-5170 October 6-9</source>
          ,
          <fpage>2014</fpage>
          - Curitiba, PR,
          <string-name>
            <surname>Brazil</surname>
          </string-name>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Floratou</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Minhas</surname>
            , U.F.,
            <given-names>O</given-names>
          </string-name>
          ¨ zcan, F.:
          <article-title>SQL-on-Hadoop: full circle back to shared-nothing database architectures</article-title>
          .
          <source>Proceedings of the VLDB Endowment</source>
          <volume>7</volume>
          (
          <issue>12</issue>
          ),
          <fpage>1295</fpage>
          -
          <lpage>1306</lpage>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Herodotou</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lim</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Luo</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Borisov</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dong</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cetin</surname>
            ,
            <given-names>F.B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Babu</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Starfish: A Self-Tuning System for Big Data Analytics</article-title>
          . In: CIDR (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Thusoo</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sarma</surname>
            ,
            <given-names>J.S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jain</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Shao</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chakka</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          , Zhang, N.,
          <string-name>
            <surname>Antony</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          , Liu,
          <string-name>
            <given-names>H.</given-names>
            ,
            <surname>Murthy</surname>
          </string-name>
          , R.:
          <article-title>Hive - A petabyte scale data warehouse using hadoop</article-title>
          .
          <source>In: Proceedings - International Conference on Data Engineering</source>
          . pp.
          <fpage>996</fpage>
          -
          <lpage>1005</lpage>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>Yanpei</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.A.</given-names>
            ,
            <surname>Katz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.H.</given-names>
            ,
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            ,
            <surname>Alspaugh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            ,
            <surname>Katz</surname>
          </string-name>
          , R.:
          <source>Interactive Query Processing in Big Data Systems: A Cross Industry Study of MapReduce Workloads. Tech. Rep. 12</source>
          , University of California, Berkeley (aug
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>