[ovs-discuss] RFC: incremental computation for OVN with DDlog

Ben Pfaff blp at ovn.org
Fri Nov 2 17:44:13 UTC 2018


I was asked in an OVN meeting to send out an email talking about what
we're working on to make ovn-northd and ovn-controller faster.  Here's
my summary.

OVN is essentially a stack of compilers.  At the top, the CMS dumps
some configuration into the northbound database (NDBB).  Then:

    1. ovn-northd centrally translates the high-level NBDB description
       into logical flows in the southbound database (SBDB).

    2. ovn-controller, on each HV, translates the SBDB logical flows
       into "physical" (OpenFlow) flows for the local hypervisor and
       passes them to ovs-vswitchd.

    3. ovs-vswitchd translates OpenFlow flows into datapath flows on
       demand as traffic appears.

Currently, OVN implements steps 1 and 2 with code that translates all
input to output in one go.  When any of the input changes, it
re-translates all of it.  This is fine for small deployments, but it
scales poorly beyond about 1000 hypervisors, at which point each
translation step begins to take multiple seconds.  Larger deployments
call for incremental computation, in which a small change in the input
requires only a small amount of computation to yield a small change in
the output.

It is difficult to implement incremental computation in C.  For
ovn-controller, two attempts have been made already.  The first attempt,
in 2016, increased code complexity without similar benefit
(https://mail.openvswitch.org/pipermail/ovs-dev/2016-August/078272.html).
A recent approach, by Han Zhou shows a much bigger improvement, but it
also increases complexity greatly and definitely makes maintenance more
difficult.

Justin and I are proposing a new approach, based on an incremental
computation engine called Differential Datalog, or DDlog for short
(https://github.com/ryzhyk/differential-datalog).  DDlog is open source
software developed at the VMware Research Group in Palo Alto by Leonid
Ryzhyk, Mihai Budiu, and others.  It uses an underlying engine developed
by Frank McSherry at Microsoft Research, called Differential Dataflow
(https://github.com/frankmcsherry/differential-dataflow).  Here's a talk
that Leonid gave on DDlog earlier this earlier:
https://ovsorbit.org/#e58

DDlog appears suitable for steps 1 and 2, that is, for both ovn-northd
and ovn-controller.  Justin and I are starting with ovn-northd, because
it is a simpler case, and once we've arrived at some minimum amount of
success, Han is going to apply what we've learned to ovn-controller as
well.  Leonid and Mihai have been working very closely with us (we have
literally been writing DDlog code in conference rooms in 90 minute
sessions with everyone clustered around laptops) and none of it could
happen without them.

Here's the process we'll need to follow to get DDlog to work with
ovn-northd:

* DDlog needs to be able to talk to OVSDB for input (reading data from
  the northbound database) and output (writing data to the southbound
  database).  Therefore, we need to write OVSDB adapters for DDlog.
  Leonid has already done an important part of this work.  There is
  more work to do plumbing the adapter into ovn-northd's database
  connections.

* We need to translate the C flow generation code in ovn-northd into
  DDlog's domain specific language.  There are some tricky parts to
  this but we expect the bulk of it to be straightforward and probably
  easier to read in DDlog than in C.  We've started with the tricky
  parts, which you can find at
  https://github.com/ryzhyk/differential-datalog/blob/northd/test/ovn/ovn_northd.dl
  Please don't take the code there as illustrative of what one would
  typically see for flow generation, because as I said, these are the
  hard parts.

* The OVN build system will need some changes:

  - The DDlog compiler, which translates .dl files into Rust, is
    written in Haskell, so Haskell becomes an OVN build requirement
    but not a runtime requirement.  (If that's a problem, then we can
    arrange to distribute the Rust output as well as the .dl input,
    for situations where Haskell is not available.)

  - OVN will require a Rust compiler at build time.  Whatever
    libraries Rust needs becomes runtime requirements.

  - ovn-northd (and eventually ovn-controller) will link against the
    Rust object files and call into DDlog through its external API.

* Initially, we plan to make DDlog optional.  If Haskell and Rust are
  available at configure and build time, ovn-northd will build in
  support for DDlog.  At ovn-northd runtime, command-line options will
  control which implementation is used; we hope to make it possible to
  run both in parallel to check for differences in behavior.  After
  the DDlog implementation is proven in practice, we hope to delete
  the C implementation entirely.

Happy to hear comments.

Ben


More information about the discuss mailing list