<!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>Parallel Bottom-Up Evaluation of Logic Programs: DeALS on Shared-Memory Multicore Machines</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>University of California</institution>
          ,
          <addr-line>Los Angeles</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2015</year>
      </pub-date>
      <history>
        <date date-type="accepted">
          <day>5</day>
          <month>6</month>
          <year>2015</year>
        </date>
      </history>
      <abstract>
        <p>Delivering superior expressive power over RDBMS, while maintaining competitive performance, has represented the main goal and technical challenge for deductive database research since its inception forty years ago. Significant progress toward this ambitious goal is being achieved by the DeALS system through the parallel bottom-up evaluation of logic programs, including recursive programs with monotonic aggregates, on a shared-memory multicore machine. In DeALS, a program is represented as an AND/OR tree, where the parallel evaluation instantiates multiple copies of the same AND/OR tree that access the tables in the database concurrently. Synchronization methods such as locks are used to ensure the correctness of the evaluation. We describe a technique which finds an efficient hash partitioning strategy of the tables that minimizes the use of locks during the evaluation. Experimental results demonstrate the effectiveness of the proposed technique - DeALS achieves competitive performance on non-recursive programs compared with commercial RDBMSs and superior performance on recursive programs compared with other existing systems.</p>
      </abstract>
      <kwd-group>
        <kwd>parallel</kwd>
        <kwd>bottom-up evaluation</kwd>
        <kwd>Datalog</kwd>
        <kwd>multicore</kwd>
        <kwd>AND/OR tree</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>MOHAN YANG, ALEXANDER SHKAPSKY, CARLO ZANIOLO</p>
    </sec>
    <sec id="sec-2">
      <title>1 Introduction</title>
      <p>
        There has been much research on improving the performance of Datalog systems
through parallel bottom-up evaluation. Previous studies focused on the message
passing model where processors communicate with each other by exchanging
messages. This includes both strategies for programs that can be evaluated without any
communication
        <xref ref-type="bibr" rid="ref12 ref15 ref15 ref16 ref16 ref4">(Wolfson and Silberschatz 1988; Wolfson 1988; Cohen and Wolfson
1989; Seib and Lausen 1991)</xref>
        and strategies to minimize the amount of
communication required
        <xref ref-type="bibr" rid="ref19 ref6 ref7">(Ganguly et al. 1992; Zhang et al. 1995; Ganguly et al. 1995)</xref>
        . In
this paper we instead assume the shared-memory model, where the data is stored
in shared-memory that can be directly accessed by all processors, as is
supported by most modern multicore machines, rather than explicit exchange of messages
through a shared segment of memory as studied in
        <xref ref-type="bibr" rid="ref15 ref16 ref6">(Wolfson and Silberschatz 1988;
Ganguly et al. 1992)</xref>
        . The shared data may be modified by multiple processors
concurrently, and synchronization methods such as locks are used to ensure the
correctness of the evaluation.
      </p>
      <p>
        The key to achieving a good performance in the shared-memory model is to
use as little synchronization as possible in the program evaluation. In this paper,
we present the technique used by the Deductive Application Language System
(DeALS)1 under development at UCLA, which extends the LDL++ technology
        <xref ref-type="bibr" rid="ref2">(Arni et al. 2003)</xref>
        , to support the parallel bottom-up evaluation of Datalog
programs on shared-memory multicore machines. The proposed technique produces
efficient evaluation plans for both non-recursive programs and recursive programs.
DeALS delivers competitive performance on the non-recursive queries of the
TPCH benchmark2, compared with the state of the art RDBMSs such as Vectorwise3
and SQL Server4, and superior performance on recursive programs compared with
other existing systems.
      </p>
      <p>The rest of this paper is organized as follows. We introduce the concept of
lockfree programs in Section 2. We describe how DeALS tries to find a lock-free
evaluation plan in Section 3. An overview of DeALS is presented in Section 4. We report
experimental results in Section 5. Related work is discussed in Section 6. The paper
concludes in Section 7.</p>
    </sec>
    <sec id="sec-3">
      <title>2 Lock-free Programs</title>
      <p>Let arc be a base relation that represents the edges of a directed graph. The
transitive closure tc of arc is a derived relation that contains all the pairs (X; Y)
where there is a path from X to Y in the graph. The following program is used to
compute tc.</p>
      <p>r1:1 : tc(X; Y) &lt;- arc(X; Y):
r1:2 : tc(X; Y) &lt;- tc(X; Z); arc(Z; Y):
The bottom-up evaluation of this program works as follows. The exit rule r1:1 is
evaluated first. A tuple (X; Y) is added to tc for each tuple (X; Y) in arc. Then the
left-linear recursive rule r1:2 is evaluated. For each tuple (X; Z) in tc, a tuple (X; Y)
is added to tc for each tuple of the form (Z; Y) in arc.5 r1:2 is repeatedly evaluated
until tc does not change between two successive evaluations of r1:2.</p>
      <p>
        Now we describe how to parallelize the bottom-up evaluation on a shared-memory
machine with n processors. The parallel evaluation strategy presented in this
paper uses the same workflow as the sequential bottom-up evaluation to ensure the
correctness of evaluation, while the parallelism is achieved through the parallel
evaluation of each single rule (including the parallel pipelined evaluation of all the
rules which support its goal as described in Section 3). As shown in our
experiments, our strategy is able to achieve a reasonable speedup for a data intensive
application to the point that we do not need to explore rules level and components
level parallelism
        <xref ref-type="bibr" rid="ref10">(Perri et al. 2013)</xref>
        .
(1)
1 Deductive Application Language System, http://wis.cs.ucla.edu/deals/.
2 TPC-H, http://www.tpc.org/tpch/.
3 Vectorwise, http://www.actian.com/.
4 SQL Server 2014, http://www.microsoft.com/en-us/server-cloud/products/sql-server/.
5 Naive evaluation is used here for simplicity. The technique described in this paper also applies
to the semi-naive evaluation.
      </p>
      <p>We divide each relation into n partitions and we use the relation name with a
superscript i to denote the i-th partition of the relation. For each partition, we use
a lock to ensure the atomicity of each write operation if multiple write operations
can occur concurrently. Let h be a hash function that maps a vertex to an integer
between 1 to n. Both arc and tc are partitioned by the first column, i.e., h(X) = i
for each (X; Y) in arci and h(X) = i for each (X; Y) in tci. Assuming that there are
one coordinator and n workers, the parallel evaluation proceeds as follows.
(1) The i-th worker evaluates r1:1 by adding a tuple (X; Y) to tc for each tuple
(X; Y) in arci.
(2) Once all workers finish Step (1), the coordinator notifies each worker to start</p>
      <p>Step (3).
(3) For each tuple (X; Z) in tci, the i-th worker looks for tuples in the form (Z; Y)
in arc and adds a tuple (X; Y) to tc.
(4) Once all workers finish Step (3), the coordinator checks if the evaluation for
tc is completed. If so, the computation terminates; otherwise the computation
starts from Step (3).</p>
      <p>In Step (1) and Step (3), each worker performs its task on one processor while the
coordinator waits. Step (2) and Step (4) serve as synchronization barriers.</p>
      <p>In Step (1), the i-th worker only writes to tci since every tuple (X; Y) it adds
to tc is taken from arci where h(X) = i. In Step (3), the i-th worker reads from
tci and only writes to tci since every tuple (X; Y) it adds to tc is derived from a
tuple (X; Z) in tci and a tuple (Z; Y) in arc where h(X) = i. There is no need for
locks since tci is only accessed by the i-th worker during evaluation. The above
evaluation plan is called a lock-free plan where no lock is needed, and a program
which has a lock-free plan is called a lock-free program.</p>
      <p>A key factor that enables a lock-free plan is the partitioning strategy. If we keep
the current partitioning for arc but instead partition tc by its second column, then
every worker could write to tci in Step (3), and an exclusive lock (x-lock) is needed
to ensure every write operation to tci is atomic. For some programs, it is possible
that a worker reads from a partition of a relation while the same partition is being
modified by another worker. In this case, a readers-writer lock (rw-lock) is needed
to ensure that every write operation is atomic, read operations will not get a tuple
that is partially updated, and concurrent read operations are allowed when the
partition is not being modified by other workers.</p>
      <p>
        Another key factor is the selection of hash functions. It is possible to get a
lockfree plan even if we use different hash functions for arc and tc. However, in this
paper we focus on the case where every relation is partitioned using the same hash
function h defined as
t
X g(xi)
i=1
h(x1;
; xt) =
mod n;
(2)
where the input to h is a tuple of any arity t, g is a hash function with a range
no less than n, and P can be replaced with any commutative function. Using a
commutative function to combine the hash values of h allows for more parallelism
than an arbitrary function, such as concatenation (jj) where h(x1; ; xt) becomes
g(x1)jj jjg(xt)
        <xref ref-type="bibr" rid="ref13 ref17">(Yang et al. 2015)</xref>
        . Next, we present a systematic approach to find
a partitioning strategy that generates a lock-free plan for an arbitrary program
when such a plan exists.
      </p>
      <p>Discriminating Sets and Parallel Program Evaluation. Consider the
evaluation of a stratifiable program P that consists of l rules r1; ; rl, where each rule ri
is in the form pi;0 &lt;- pi;1; ; pi;mi . Here pi;0 is a predicate that serves as the head
of ri, mi is the number of predicates in the body of ri, and each pi;j is a predicate in
the body for j = 1; ; mi. Assume that a predicate p is associated with a relation
of the same name and arity as the predicate, and we use R(p) to denote the relation
that stores all tuples corresponding to facts about p in memory. A discriminating
set of a (non-nullary) relation R is a non-empty subset of columns in R. Given a
discriminating set of a relation, we divide the relation into n partitions by the hash
values of the columns that belong to the discriminating set.</p>
      <p>Let Pj be the program to be executed by the j-th worker. For each rule ri, we
add the following rule in Pj :
j
ri : pi;0 &lt;- pi;1;
; pi;mi ; h(pi;ti [Xi]) = j;
(3)
where pi;ti is a predicate selected from the mi predicates in the body for a ti between
1 to mi, Xi is a selected discriminating set of R(pi;ti ), pi;ti [Xi] denotes a tuple of
arity jXij by retrieving the arguments in pi;ti whose positions belong to Xi, and
the last predicate h(pi;ti [Xi]) = j means a tuple from the j-th partition of R(pi;ti )
is accessed in every successful derivation of rij . We select the same pi;ti and Xi for
j = 1; ; n. We also select a discriminating set, denoted by X(R), for each derived
relation R. These discriminating sets can be arbitrarily selected as long as there
is a unique discriminating set for each derived relation. We might have selected
several different discriminating sets of the same base relation which correspond to
different ways of partitioning the relation. This relation is preprocessed before the
evaluation so that it can be efficiently accessed for every partitioning.</p>
      <p>In general, the parallel evaluation proceeds as follows.
(1) The coordinator determines the first rule to be evaluated, say ri, and instructs
the workers to start Step (2).
(2) All n workers become active with the j-th worker evaluating rij .
(3) After all workers finish, the coordinator checks if the evaluation for P is
completed. If not, it determines the next rule to be evaluated and Step (2) repeats.</p>
      <p>
        The parallel evaluation scheme described above is a special case of the substitution
partitioned scheme
        <xref ref-type="bibr" rid="ref6">(Ganguly et al. 1992)</xref>
        . Our scheme improves it by removing the
sending, receiving and final pooling steps since each worker has full access to all the
relations in the shared-memory model.
      </p>
      <sec id="sec-3-1">
        <title>Example 1</title>
        <p>The corresponding Pj in the lock-free plan for the program in (1) is shown as
follows.</p>
        <p>r4:1 : tc(X; Y) &lt;- arc(X; Y); h(X) = j:
r4:2 : tc(X; Y) &lt;- tc(X; Z); arc(Z; Y); h(X) = j:</p>
        <p>
          For each worker, there are still many different ways to evaluate r4:2 since the
three predicates in the body can be evaluated in different orders. For a specific
order, a bound/free adornment
          <xref ref-type="bibr" rid="ref14">(Ullman 1985)</xref>
          of a predicate p is a string of b’s
and f’s whose length equals the arity of p, where a b (an f) in the i-th position
means the i-th argument in p is bound (free) when p is evaluated. We force the
same bottom-up evaluation plan upon every worker by using the same bound/free
adornments for every Pj.
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>Example 2</title>
        <p>The program in (5) shows an adorned version of the program in Example 1. The
predicates in r5:2 are reordered to reflect the order in which they are evaluated.
In the evaluation of r5:2, the j-th worker evaluates tcff(X; Z); h(X) = j by reading
from the j-th partition of tc. Then it evaluates arcbf(Z; Y) where Z is bound. So it
finds a tuple (Z; Y) from arc with the given Z, and adds (X; Y) to tc if it succeeds.
r5:1 : tcff(X; Y) &lt;- arcff(X; Y); h(X) = j:
r5:2 : tcff(X; Y) &lt;- tcff(X; Z); h(X) = j; arcbf(Z; Y):
attendf(X) &lt;- organizerf(X); h(X) = j:
attendf(Y) &lt;- cntfriendsff(Y; N); h(Y) = j; N
3:</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>3 Parallel Evaluation of AND/OR Trees</title>
      <p>
        In DeALS, a program is represented as an AND/OR tree
        <xref ref-type="bibr" rid="ref2">(Arni et al. 2003)</xref>
        . An
OR node represents a predicate and an AND node represents the head of a rule.
The root is an OR node. The children of an OR node and an AND node are AND
nodes and OR nodes, respectively. There are specialized OR nodes, such as the
R-node that reads from a base relation or a derived relation and the W-node that
writes to a derived relation. We use a pipelined evaluation which only materializes
      </p>
      <sec id="sec-4-1">
        <title>Example 3</title>
        <p>
          The attend program below finds all the people who will attend the party. A person
will attend the party if he/she is an organizer, or he/she has at least three friends
who will attend the party. Here, mcount is the monotonic and continuous count
aggregate
          <xref ref-type="bibr" rid="ref13 ref17">(Shkapsky et al. 2015)</xref>
          .
(5)
(6)
(7)
cntfriends(Y; mcount&lt;X&gt;) &lt;- friend(X; Y); attend(X):
attend(X) &lt;- organizer(X):
attend(Y) &lt;- cntfriends(Y; N); N
3:
The program in (7) shows a lock-free evaluation plan. Each relation is partitioned
by its first column except friend is partitioned by its second column. In each
iteration, the j-th worker scans through the j-th partition of friend, and checks
if there is a specific X in attend which can be efficiently supported by maintaining
an index on attend during program evaluation. Thus, the j-th worker only writes
to the j-th partition of cntfriends and attend, and no lock is needed.
        </p>
        <p>cntfriendsff(Y; mcount&lt;X&gt;) &lt;- friendff(X; Y); h(Y) = j; attendb(X):
relations when it is necessary — if 1) it is the root; or 2) it is an aggregation; or
3) the optimizer determines that the cost of computing the tuples when they are
needed is much higher than the cost of materializing the relation in memory.6</p>
        <p>A program is transformed into an AND/OR tree such that the root represents the
query and the children of each AND node follow the same order as the corresponding
predicates in the corresponding rule. The AND/OR tree is then adorned for
bottomup evaluation. An OR node is an entry node if 1) it is a leaf, and 2) it is the first
R-node among its siblings, and 3) each of its ancestor OR node does not have a
left-sibling (i.e., a sibling that appears before the current node) that has an R-node
descendant or a W-node descendant.</p>
      </sec>
      <sec id="sec-4-2">
        <title>Example 4</title>
        <p>A non-linear formulation of the transitive closure program is shown as follows.
tc(X; Y) &lt;- arc(X; Y):
tc(X; Y) &lt;- tc(X; Z); tc(Z; Y):
(8)
The corresponding AND/OR tree is shown in Fig. 1. The text description inside a
node indicates the type and ID of the node, e.g., “OR-1” indicates the root is an
OR node with ID 1. OR-4, OR-5 and OR-6 are R-nodes and OR-1 is a W-node.
OR-4 and OR-5 are entry nodes in this program.</p>
        <p>OR-1 tc(X, Y)
tc(X, Y) AND-2</p>
        <p>AND-3 tc(X, Y)
arc(X, Y) OR-4 tc(X, Z) OR-5</p>
        <p>OR-6 tc(Z, Y)</p>
        <p>In DeALS, the j-th worker evaluates an entry node by instantiating variables
with constants from the j-th partition of the corresponding relation. For the
remaining R-nodes, each worker has full access to all partitions of the corresponding
relations. This strategy ensures that the evaluation is divided into n disjoint parts;
otherwise if each worker evaluates an entry node by instantiating variables with
constants from all partitions of the corresponding relation, redundant work will be
performed. 1
Determining the Discriminating Sets. Now we describe the read/write analysis
on an adorned AND/OR tree that determines the type of lock needed for each
derived relation. The analysis performs a depth-first traversal on the AND/OR
tree that simulates the actual evaluation to check each read or write operation
performed by the j-th worker. For each node encountered during the traversal:
6 Currently this is done manually where a user can force the materialization of a relation by an
annotation in the program.
(1) if it is an entry node, set it as the current entry node; if it reads from a derived
relation, for each W-node that is an ancestor of the current node,7 determine
if the j-th worker only writes to the j-th partition of R(pw) by checking if
pe[Xj ] = pw[Xk]8, where pe and pw are the predicates associated with the
entry node and W-node, respectively, and Xj and Xk are the corresponding
discriminating sets;
(2) if it is an R-node that reads from a derived relation, determine if the j-th
worker only reads from the j-th partition of R(pr) by checking if Xk B
and pe[Xj ] = pr[Xk], where pe and pr are the predicates associated with the
current entry node and R-node, respectively, Xj and Xk are the corresponding
discriminating sets, and B is the set of positions for bound arguments in the
R-node.</p>
        <p>
          We use the following discriminating set equations (DSE) obtained through a
read/write analysis to find the best possible discriminating sets for a given program.
A DSE consists of three types of equations:
(1) pe[Xj ] = pw[Xk] for each entry node in Case (1) of the read/write analysis;
(2) Xk B, pe[Xj ] = pr[Xk] for each R-node in Case (2) of the read/write analysis;
(3) ; ( X f1; ; arity(R)g for each X appearing in the above two types of
equations, where arity(R) is the arity of the relation R associated with X.
The target is to find an optimal solution to the DSE which is an assignment to the
variables that satisfies all the equations of Type (3) and maximizes the number of
satisfied equations of Type (1) and Type (2). DeALS finds an optimal solution by
enumerating all possible assignments, which is feasible for most recursive programs
studied in the literature since the number of variables is very small. DSE is very
similar to the idea of generalized pivoting where a system of equations is obtained
from the rules and an exact solution is required
          <xref ref-type="bibr" rid="ref12">(Seib and Lausen 1991)</xref>
          . But it
is different from generalized pivoting in two aspects: 1) DSE is obtained through
the read/write analysis on the AND/OR tree since the pipelined evaluation on the
AND/OR tree might evaluate multiple rules at the same time where the equations
obtained from each single rule cannot capture all the constraints; 2) an exact
solution is not required since we want to obtain the best possible evaluation plan
even when the program cannot be evaluated without any communication under the
message passing model.
        </p>
        <p>
          Finally, the discriminating sets are determined as follows.
(1) Obtain the DSE by performing a read/write analysis on the AND/OR tree.
(2) Find an optimal solution to the DSE.
(3) Determine the type of lock for each derived relation by a read/write analysis
on the AND/OR tree with the selected discriminating sets.
7 The set of ancestor W-nodes of an entry node can be efficiently obtained using a stack during
the traversal
          <xref ref-type="bibr" rid="ref13 ref17">(Yang et al. 2015)</xref>
          . The details are omitted due to space constraints.
8 The tuple denoted by p[X] is treated as a multiset of arguments when involved in equality
checking.
        </p>
      </sec>
      <sec id="sec-4-3">
        <title>Example 5</title>
        <p>The DSE for the AND/OR tree in Fig. 1 is shown is shown below.
arc(X; Y)[X1] = tc(X; Y)[X2]
tc(X; Z)[X2] = tc(X; Y)[X2]
X2 f1g
tc(X; Z)[X2] = tc(Z; Y)[X2]
; ( X1
; ( X2
f1; 2g
f1; 2g
(9)
The optimal solution is X1 = X2 = f1g that only violates the fourth equation. The
result of a read/write analysis determines that an rw-lock is needed for tc in the
evaluation of the non-linear recursive rule.</p>
        <p>We assume the program does not contain aggregates and arithmetic expressions
in the above procedure. If the program does contain these constructs, the same
procedure is applicable if we ignore all the arguments which are either aggregates
or arithmetic expressions. The only exception is that the evaluation of a W-node
always requires locks if it contains an aggregate with no group by arguments.</p>
        <p>4 DeALS
DeALS is a Datalog system under development at UCLA. It has a Java-based
compiler and a sequential Java-based interpreter that allows users to develop and
debug their applications. The new parallel evaluation module targeted for
sharedmemory multicore machines is implemented as a separate module in the system
— the compiler compiles a program into an AND/OR tree and then the parallel
module determines the parallel evaluation plan using the technique presented in this
paper and generates a corresponding C++ program. We implemented the database
objects (index and storage), base classes for each kind of node in the AND/OR tree
and common functions. The generated program contains the definition of tuples
and relations, and the actual implementation of the AND/OR tree based on the
base classes. It is compiled into the final executable by invoking the Visual C++
Compiler that comes with Visual Studio 2013 (v120) on a Windows machine or GCC
4.9.2 on a Linux machine. The thread implementation provided by the Microsoft
Windows runtime library is used on a Windows machine to evaluate the query in
parallel, while Pthreads is used on a Linux machine.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5 Experimental Results</title>
      <p>In this section, we report some experimental results on evaluating both non-recursive
and recursive programs. The test machine has four AMD Opteron 6376 CPUs (16
cores per CPU) and 256GB memory (configured into eight NUMA regions). The
operating system is Ubuntu Linux 12.04 LTS. All execution times are calculated by
taking the average of five runs of the same experiment.
1.143
1</p>
      <p>
        DeALS
VectorWise 2.0.1
SQL Server 2014
7.755
Exp-I: Non-recursive programs — TPC-H benchmark. The benchmark
contains 22 (non-recursive) SQL queries over a database of eight tables. The data types
involved in the queries are integer, decimal, string and date. We implemented all the
22 queries following the query plans described in
        <xref ref-type="bibr" rid="ref5">(Dees and Sanders 2013)</xref>
        .9 DeALS
is able to correctly evaluate all the 22 queries on databases of size 1GB, 10GB and
100GB on the test machine, with a speedup of 12.43, 19.48, 23.63, respectively
(evaluation time for all the 22 queries using one processor divides the time using
60 processors). Fig. 2 shows the total query evaluation time for all the 22 queries.
The last point 831.711s shows the predicted time on a database of size 1TB if the
evaluation time scales linearly w.r.t. the size of the database. We compare DeALS
with the current single machine world record for the benchmark on databases of size
100GB and 1TB. VectorWise 2.0.1 evaluates all the queries in 22.8s on a database
of size 100GB,10 while it takes Microsoft SQL Server 2014 Enterprise Edition 138s
on a database of size 1TB.11 Note that the SPECint_rate2006 of our test machine
is 1050 (the larger the more powerful), while the values are 695 and 2400 for the
other two machines. Fig. 2 shows the predicted time of both commercial RDBMSs
on our test machine if the evaluation time is inversely proportional to the
SPECint_rate2006 of the machine. DeALS is within six times slower comparing with these
two highly optimized commercial systems (both system settings are also optimized
for the benchmark).
      </p>
      <p>Exp-II: Recursive programs. We test the performance of DeALS on three
classical recursive queries — tc (program in (1)), attend (program in Example 3) and
sg (same generation) as shown below:
sg(X; Y) &lt;- anc(P; X); anc(P; Y); X 6= Y:
sg(X; Y) &lt;- anc(A; X); sg(A; B); anc(B; Y):
(10)
The test datasets contain synthetic graphs and real world graphs.
9 COUNT(DISTINCT) is replaced with COUNT in query16. ORDER BY and LIMIT are ignored in
our program. The evaluation time will not change significantly if we add these constructs since
most queries return very few results except query3 and query10.
10 TPC-H Result on Dell PowerEdge R720, http://www.tpc.org/3282.
11 TPC-H Result on Cisco UCS C460 M4 Server, http://www.tpc.org/3311.
.02 .02
27 17 26
2
.</p>
      <p>6
tree-11</p>
    </sec>
    <sec id="sec-6">
      <title>Synthetic Graphs</title>
      <p>1) tree-11 is a randomly generated tree of depth 11 where the out degree of a
non-leaf vertex is a random number between 2 to 6.
2) grid-150 is a 151 151 square grid.
3) gnp-10K is a random graph (Erdős-Rényi model) of 10,000 vertices generated by
connecting vertices randomly such that the average out-degree of a vertex is 10.</p>
    </sec>
    <sec id="sec-7">
      <title>Real World Graphs</title>
      <p>1) patent is the US patent citation graph12. Each vertex represents a patent, and
each edge represents a citation between two patents. It has 3,774,769 vertices
and 16,518,948 edges.
2) wiki is the Wikipedia knowledge graph. Each vertex represents an entity in the
Wikipedia, and each edge represents an appearance of an entity in another
entity’s infobox. It has 3,165,181 vertices and 23,190,820 edges.</p>
      <p>The experiments on tc (sg) evaluation use each of these synthetic graphs as arc
(anc). The experiments on attend evaluation use each real world graphs as friend,
while organizer contains all the vertices in the graph whose in-degrees are zero.</p>
      <p>
        We compare DeALS with LogicBlox 4.1.9
        <xref ref-type="bibr" rid="ref1">(Aref et al. 2015)</xref>
        and DLV
        <xref ref-type="bibr" rid="ref9">(Leone et al.
2006)</xref>
        , which are two systems that represent the state of the art in evaluating logic
programs in the areas of deductive database and disjunctive logic programming,
respectively. Both DeALS and LogicBlox support all three queries and evaluate
them correctly on the test datasets. DLV runs out of memory on our test machine
on the evaluation of sg on tree-11. The version of DLV13 that supports aggregates
in recursion is a 32-bit executable which fails on the evaluation of attend on both
patent and wiki as it does not support more than 4GB memory required by
evaluation. Fig. 3 compares the evaluation time of three systems on these recursive
queries. Bars for LogicBlox show the evaluation time of LogicBlox using 64
processors.14 Bars for DLV show the evaluation time of DLV using one processor.15
12 Patent citation network, https://snap.stanford.edu/data/cit-Patents.html.
13 DLV with Recursive Aggregates, downloaded from http://www.dbai.tuwien.ac.at/proj/dlv/
dlvRecAggr/dl-recagg-snapshot-2007-04-14.zip.
14 In our experiments, LogicBlox 4.1.9 does not utilize all the processors all the time.
15 The single-processor version of DLV is downloaded from http://www.dlvsystem.com/files/
dlv.x86-64-linux-elf-static.bin. Although a parallel version (http://www.mat.unical.it/
ricca/downloads/parallelground10.zip) is available, it is either much slower than the
singleprocessor version or it fails since it is a 32-bit executable that does not support more than 4GB
memory required by evaluation.
Bars for DeALS-1 and DeALS-64 show the evaluation time of DeALS using one
processor and 64 processors, respectively. When DeALS uses only one processor,
it always outperforms DLV on these queries and datasets, and it outperforms or
equally performs LogicBlox. DeALS always outperforms LogicBlox when it uses 64
processors. It achieves a greater speedup (the speedup of DeALS-64 over DeALS-1)
for tc and attend than sg since no lock is used in tc and attend, while sg suffers
from lock contention. It achieves limited speedup for tc on tree-11 since evaluation
time is dominated by barrier synchronization overhead
        <xref ref-type="bibr" rid="ref13 ref17">(Yang et al. 2015)</xref>
        .
      </p>
    </sec>
    <sec id="sec-8">
      <title>6 Related Work</title>
      <p>
        The parallel evaluation strategy proposed in this paper uses a simple hash-based
data partitioning strategy. Various data partitioning strategies for parallel
bottomup evaluation have been studied in
        <xref ref-type="bibr" rid="ref12 ref15 ref15 ref16 ref16 ref19 ref4 ref6 ref7">(Wolfson and Silberschatz 1988; Wolfson 1988;
Cohen and Wolfson 1989; Seib and Lausen 1991; Ganguly et al. 1992; Zhang et al.
1995; Ganguly et al. 1995)</xref>
        . These studies assume a message passing model and
focus on minimizing the amount of message exchange, whereas our study considers
a shared-memory model where no message exchange is needed during the
evaluation; we demonstrate the effectiveness of our technique with a real Datalog system
implementation while previous studies focus on the theoretical aspect. The settings
of
        <xref ref-type="bibr" rid="ref11 ref3 ref8">(Raschid and Su 1986; Hulin 1989; Bell et al. 1991)</xref>
        are more similar to ours,
where strategies for top-down evaluation are proposed. These strategies are
complementary to ours since we focus on the bottom-up evaluation. Yet another related
work is our ongoing research which aims to provide a distributed evaluation engine
for DeALS. However, the study presented in this paper focus on the case where all
the base relations and derived relations fit into the memory of a single machine.
      </p>
    </sec>
    <sec id="sec-9">
      <title>7 Conclusion</title>
      <p>
        In this paper, we presented the technique used in DeALS for parallel
bottomup evaluation on shared-memory multicore machines. The technique is simple and
applicable to a wide range of non-recursive and recursive programs. DeALS is
able to achieve competitive performance on non-recursive programs compared with
RDBMSs and superior performance on recursive programs compared with other
existing systems, by adding a parallel evaluation module based on this technique.
However, there is still a clear performance gap between DeALS and the hand
written optimal programs, such as the SSC12 algorithm for transitive closure
        <xref ref-type="bibr" rid="ref18">(Yang
and Zaniolo 2014)</xref>
        . We are working on reducing the gap by further optimizing
the performance of the generated program. Another ongoing work is to provide
a parallel evaluation module targeted for distributed environment that is able to
solve problems when the dataset does not fit into the memory of a single machine.
We are also working on optimizing the support for and the performance of new
applications requiring data mining and graph analysis.
      </p>
    </sec>
    <sec id="sec-10">
      <title>Acknowledgment</title>
      <p>This work was supported by NSF grants IIS 1218471 and IIS 1118107. We would
like to thank the reviewers and Matteo Interlandi for their comments. We thank
LogicBlox especially Martin Bravenboer, Dung Nguyen, and Yannis Smaragdakis,
for their assistance with the LogicBlox comparison.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <surname>Aref</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>ten Cate</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Green</surname>
            ,
            <given-names>T. J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kimelfeld</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          , et al.
          <year>2015</year>
          .
          <article-title>Design and implementation of the logicblox system</article-title>
          .
          <source>In SIGMOD 2015. ACM</source>
          ,
          <volume>1371</volume>
          -
          <fpage>1382</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <surname>Arni</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ong</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tsur</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Zaniolo</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <year>2003</year>
          .
          <article-title>The deductive database system LDL++</article-title>
          .
          <source>TPLP 3</source>
          ,
          <issue>1</issue>
          ,
          <fpage>61</fpage>
          -
          <lpage>94</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <surname>Bell</surname>
            ,
            <given-names>D. A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Shao</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Hull</surname>
            ,
            <given-names>M. E. C.</given-names>
          </string-name>
          <year>1991</year>
          .
          <article-title>A pipelined strategy for processing recursive queries in parallel</article-title>
          .
          <source>Data &amp; Knowledge Engineering 6</source>
          ,
          <issue>5</issue>
          ,
          <fpage>367</fpage>
          -
          <lpage>391</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <surname>Cohen</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          and
          <string-name>
            <surname>Wolfson</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          <year>1989</year>
          .
          <article-title>Why a single parallelization strategy is not enough in knowledge bases</article-title>
          .
          <source>In PODS 1989. ACM</source>
          ,
          <volume>200</volume>
          -
          <fpage>216</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <surname>Dees</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          and
          <string-name>
            <surname>Sanders</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <year>2013</year>
          .
          <article-title>Efficient many-core query execution in main memory column-stores</article-title>
          .
          <source>In ICDE 2013. IEEE</source>
          ,
          <fpage>350</fpage>
          -
          <lpage>361</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <surname>Ganguly</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Silberschatz</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Tsur</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <year>1992</year>
          .
          <article-title>Parallel bottom-up processing of datalog queries</article-title>
          .
          <source>The Journal of Logic Programming</source>
          <volume>14</volume>
          ,
          <issue>1</issue>
          ,
          <fpage>101</fpage>
          -
          <lpage>126</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <surname>Ganguly</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Silberschatz</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Tsur</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <year>1995</year>
          .
          <article-title>Mapping datalog program execution to networks of processors</article-title>
          .
          <source>TKDE 7</source>
          ,
          <issue>3</issue>
          ,
          <fpage>351</fpage>
          -
          <lpage>361</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <string-name>
            <surname>Hulin</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <year>1989</year>
          .
          <article-title>Parallel processing of recursive queries in distributed architectures</article-title>
          .
          <source>In VLDB 1989</source>
          . Morgan Kaufmann Publishers Inc.,
          <fpage>87</fpage>
          -
          <lpage>96</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <string-name>
            <surname>Leone</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pfeifer</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Faber</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Eiter</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gottlob</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          , et al.
          <year>2006</year>
          .
          <article-title>The dlv system for knowledge representation and reasoning</article-title>
          .
          <source>TOCL 7</source>
          ,
          <issue>3</issue>
          ,
          <fpage>499</fpage>
          -
          <lpage>562</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          <string-name>
            <surname>Perri</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ricca</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Sirianni</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <year>2013</year>
          .
          <article-title>Parallel instantiation of asp programs: techniques and experiments</article-title>
          .
          <source>TPLP 13</source>
          ,
          <issue>02</issue>
          ,
          <fpage>253</fpage>
          -
          <lpage>278</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          <string-name>
            <surname>Raschid</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          and
          <string-name>
            <surname>Su</surname>
            ,
            <given-names>S. Y. W.</given-names>
          </string-name>
          <year>1986</year>
          .
          <article-title>A parallel processing strategy for evaluating recursive queries</article-title>
          .
          <source>In VLDB 1986</source>
          . Morgan Kaufmann Publishers Inc.,
          <fpage>412</fpage>
          -
          <lpage>419</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          <string-name>
            <surname>Seib</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          and
          <string-name>
            <surname>Lausen</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <year>1991</year>
          .
          <article-title>Parallelizing datalog programs by generalized pivoting</article-title>
          .
          <source>In PODS 1991. ACM</source>
          ,
          <volume>241</volume>
          -
          <fpage>251</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          <string-name>
            <surname>Shkapsky</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yang</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Zaniolo</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <year>2015</year>
          .
          <article-title>Optimizing recursive queries with monotonic aggregates in deals</article-title>
          .
          <source>In ICDE 2015. IEEE</source>
          ,
          <fpage>867</fpage>
          -
          <lpage>878</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          <string-name>
            <surname>Ullman</surname>
            ,
            <given-names>J. D.</given-names>
          </string-name>
          <year>1985</year>
          .
          <article-title>Implementation of logical query languages for databases</article-title>
          .
          <source>TODS 10</source>
          ,
          <issue>3</issue>
          ,
          <fpage>289</fpage>
          -
          <lpage>321</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          <string-name>
            <surname>Wolfson</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          <year>1988</year>
          .
          <article-title>Sharing the load of logic-program evaluation</article-title>
          .
          <source>In DPDS 1988</source>
          . IEEE Computer Society Press,
          <fpage>46</fpage>
          -
          <lpage>55</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          <string-name>
            <surname>Wolfson</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          and
          <string-name>
            <surname>Silberschatz</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <year>1988</year>
          .
          <article-title>Distributed processing of logic programs</article-title>
          .
          <source>In SIGMOD 1988. ACM</source>
          ,
          <volume>329</volume>
          -
          <fpage>336</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          <string-name>
            <surname>Yang</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Shkapsky</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Zaniolo</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <year>2015</year>
          .
          <article-title>Parallel bottom-up evaluation of logic programs: DeALS on shared-memory multicore machines</article-title>
          .
          <source>Tech. Rep. 150003</source>
          ,
          <string-name>
            <surname>UCLA</surname>
            <given-names>CSD</given-names>
          </string-name>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          <string-name>
            <surname>Yang</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          and
          <string-name>
            <surname>Zaniolo</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <year>2014</year>
          .
          <article-title>Main memory evaluation of recursive queries on multicore machines</article-title>
          .
          <source>In IEEE BigData</source>
          <year>2014</year>
          . IEEE,
          <fpage>251</fpage>
          -
          <lpage>260</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          <string-name>
            <surname>Zhang</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          , and
          <string-name>
            <surname>Chau</surname>
          </string-name>
          , S.-C.
          <year>1995</year>
          .
          <article-title>Data partition and parallel evaluation of datalog programs</article-title>
          .
          <source>TKDE 7</source>
          ,
          <issue>1</issue>
          ,
          <fpage>163</fpage>
          -
          <lpage>176</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>