arXiv:2610.39017cs.DCOct 2026

Manuscript Offprint

arXiv:2610.39017

DistOptimize: Automatic Optimization of Distributed Protocols

David Chu McElroy, Shadaj Laddad, Lucky Katahanas, Mingwei Samuel, Octavio Lomeli, Natacha Crooks, Joseph M. Hellerstein, Mohsen Lesani

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

David Chu McElroy

UC Berkeley

thedavidchu@berkeley.edu

Shadaj Laddad

Amazon Web Services

shadajl@amazon.com

Lucky E. Katahanas

Amazon Web Services

luckykat@amazon.com

Mingwei Samuel

Amazon Web Services

mingwes@amazon.com

Octavio Lomeli

UC Berkeley

octavio.lomeli@berkeley.edu

Natacha Crooks

UC Berkeley and AWS

ncrooks@berkeley.edu

Joseph M. Hellerstein

UC Berkeley and AWS

hellerstein@berkeley.edu

Mohsen Lesani

UCSC

mlesani@ucsc.edu

Abstract

Distributed consensus and consistency protocols are difficult to reason about yet foundational to the cloud; as such, they often undergo a rigorous proof and formal verification process before deployment. The same level of rigor is rarely applied to protocol modifications, which occur frequently in production and threaten to compromise safety. In this paper, we eliminate the risk of safety violations from manual modifications by presenting an automatic optimizer for distributed protocols: DISTOPTIMIZE. DISTOPTIMIZE adapts throughput optimizations from academic languages to frameworks used in production, verifying the correctness of the rewrites in Rocq and automating their application through a combination of calibration and ILP-based search space navigation. Applied to both fundamental distributed protocols and protocols used at AWS, DISTOPTIMIZE improves throughput by up to 4x and increases latency by at most 0.3ms.

1 Introduction

The services that form the foundation of modern cloud computing—like AWS S3 [4], Kubernetes [25], and Spanner [36]—rely on distributed consensus and consistency protocols to handle fault tolerance, concurrency, and availability. These distributed protocols are complex yet mission-critical; bugs can cause cross-service outages that cost hundreds of millions of dollars [1]. As such, they are held to a high standard: both academia and industry [21] invest heavily in proofs in order to guarantee correctness at launch.

Yet much less care is given to the evolution of these protocols. Service providers constantly revise and redeploy protocols, creating implementations that diverge from their formal models, increasing the risk of already-prevalent bugs [72] while adding complexity that, when combined with the existing interwoven logic of distributed protocols, ultimately makes the codebase unmaintainable. The pace of protocol evolution does not appear to be slowing down: internal discussions within AWS revealed that one such protocol is being updated roughly once every two weeks.

This paper proposes an alternative—the replacement of manual modifications with automated, semantic-preserving optimizations.

Assuming that the initial implementation of a distributed protocol is correct—and may in fact contain details omitted from its formal model [30]—our goal is to rewrite it in a way that improves performance while preserving semantics, and therefore, correctness.

We target throughput, a common concern across distributed protocols [20, 31, 41, 75, 86, 91], and reuse generic rewrites formalized in prior work [32, 33] over protocols written in Dedalus [13, 14], a relational algebra based on Datalog ∗^{*}. Our challenge is to automate these rewrites while meeting deployment standards.

The first concern is safety: high standards of correctness at AWS necessitate formal verification [21]. The complexity arises when considering our target language, Hydro [6, 55, 74]. As a dataflow language used in production at AWS, Hydro is significantly more expressive than Dedalus, supporting 55 unique operators—many of which can contain Rust UDFs (User-Defined Functions)—in addition to novel constructs for data ordering. We must formally define and verify our rewrites within a semantics that is expressive enough to describe Hydro without enumerating its operators.

The second concern is performance. Our optimizer must automatically identify rewrites that improve throughput without significantly increasing latency. A naive iteration over the space of possible rewrites is infeasible: in our implementation of Paxos [81] in Hydro, there are more than 102210^{22} unique ways to rewrite the proposer.

We address both in DISTOPTIMIZE, the first end-to-end automatic optimizer for distributed protocols.

We begin with a formalism for distributed dataflow that captures both Hydro semantics and DISTOPTIMIZE's rewrites. We use a generic transition function to describe arbitrary operators regardless of their statefulness or fan-in/fan-out. We model operator distribution and ordering constraints with the type system, using it to verify that rewrites respect constraints and that the outputs of any rewritten dataflow are equivalent to the outputs of the original. Our proofs are machine-checked in Rocq.

We then integrate the rewrites into DISTOPTIMIZE, combining a profile-based cost model with ILP (Integer Linear Programming) in order to find the most efficient application of rewrites (Figure 1).

Within the cost model, we place special emphasis on networking, because, due to a combination of context switching and user-space/kernel-space batching, it emerges as a dominant source of CPU (not bandwidth!) overhead across distributed protocols.

Figure

This work is licensed under a Creative Commons Attribution 4.0 International License.

David Chu McElroy, Shadaj Laddad, Lucky E. Katahanas, Mingwei Samuel, Octavio Lomeli, Natacha Crooks, Joseph M. Hellerstein, and Mohsen Lesani

Figure

Figure 1: Overview of DISTOPTIMIZE.

Our ILP formulation then combines rewrite precondition analysis with cost estimation, capturing cases where the application of one rewrite, though inefficient on its own, is worthwhile because it enables another. Across protocols, the ILP solver takes at most 30 seconds to find rewrites within 0.01% of the optimum.

We implement two rewrites in DISTOPTIMIZE—decoupling (task parallelism) and partitioning (data parallelism)—which have been shown to rival the performance of bespoke rewrites when manually applied to distributed protocols [31, 32, 75, 86, 91]. We evaluate DISTOPTIMIZE on distributed protocols including Paxos [81], a standard fault-tolerant consensus protocol, and a distributed compare-and-swap register. We additionally reimplement two internal protocols within AWS and evaluate the efficacy of DISTOPTIMIZE using CI (Continuous Integration) tests from existing production pipelines.¹

Across protocols, DISTOPTIMIZE improves throughput by 1.5–4× while increasing latency by at most 0.3ms.

In summary, we make the following contributions:

(1) We define a formal model for distributed dataflow and prove that the transformations preserve semantics (Section 2).

(2) We describe DISTOPTIMIZE's calibration process and model the search space of optimizations as an ILP problem (Section 3).

(3) We demonstrate the efficacy of the optimizer across distributed protocols (Section 4).

Limitations. DISTOPTIMIZE does not synthesize protocols based on specifications, nor does it verify implementations against formal models; it merely produces an optimized protocol that is semantically equivalent to the original. Therefore, given an incorrect protocol, DISTOPTIMIZE will produce an optimized and similarly incorrect protocol.

DISTOPTIMIZE's optimizations are conservative and prioritize safety, but its mechanism for detecting UDF side-effects can be circumvented by a motivated developer; similar limitations are present in other production dataflow frameworks [3, 7–9, 39].

Correctness aside, like other Profile-Guided Optimizers [18, 48, 53, 61, 62], DISTOPTIMIZE's cost model is informed by workload profiles. As such, the produced protocol may perform poorly if the workload or testing environment is not representative of conditions in reality.

Finally, decoupling and partitioning may improve throughput but reduce availability; though they do not alter the number of tolerated failures, new machines increase the probability of failure.

References (31)