arXiv:2609.06982cs.DCSep 2026

Manuscript Offprint

arXiv:2609.06982

TreeRedux: Separating Concerns in Spark's Distributed Tree Aggregation

David A. G. Harrison, Ivan Cao

David A. G. Harrison*

Computer and Information Science

University of Mississippi

Oxford, MS, USA

daharri6@olemiss.edu

Ivan Cao

Computer and Information Science

University of Mississippi

Oxford, MS, USA

icao@go.olemiss.edu

Abstract—By default, Apache Spark's tree aggregation primitives place the tree root on the driver, requiring the driver to participate in the same aggregation computation over intermediate aggregation state as executor nodes. For large aggregates, this can expose the single coordinator to substantial computation and memory requirements.

Recent Spark versions optionally move the root to an executor, but the completed aggregate must still be returned to and materialized on the driver. We demonstrate this limitation using exact quantile computation and heavy-hitter identification, where the intermediate aggregation state can be substantially larger than the desired final result.

We propose TreeRedux, a minimal extension that adds a terminal finalize operation U→VU \to V executed on an executor, allowing the compact result VV rather than the potentially large aggregation state UU to be materialized on the driver.

For exact quantile computation, applying TreeRedux to GK Select removes the driver's εn\varepsilon n memory term, reducing driver memory requirements to the same asymptotic order as Spark's GK Sketch. In our experiments, the default GK Select implementation encountered a driver OOM at 2.5 billion elements. Spark's executor-side final aggregation option extended this limit to approximately 16–18 billion elements but still required the final aggregation state to be materialized on the driver. Redux Select completed through 28 billion elements without a driver OOM. TreeRedux allowed Space-Saving sketches with up to 32×32\times the capacity of the largest configuration that materializes a full sketch on the driver.

I. INTRODUCTION

Modern distributed data-processing systems are commonly built around a shared-nothing architecture [1], in which each worker has its own CPU, memory, and storage, and communication between workers occurs through explicit data exchange rather than shared memory. This architecture enables horizontal scaling when computation can be decomposed and moved toward its data.

A defining characteristic of shared-nothing systems is the separation between workers and coordinators. Workers perform data-intensive operations using local computation and

memory, while coordinators manage execution and collect results. This asymmetry enables systems to scale by adding workers without requiring the coordinator to process data at the same scale. Typically worker failure affects only tasks and state associated with that worker, and the coordination layer reassigns the work to another worker.

Shared-nothing architectures have become particularly prevalent in cloud-scale data processing because their independent-resource model maps naturally onto cloud infrastructure, where computation is provisioned as networked virtual machines, and wherein each virtual machine has its own local processing, memory and storage.

Apache Spark is a prominent distributed data-processing system that exemplifies the shared-nothing architecture. In Spark terminology, each data processing application has a driver which coordinates execution and schedules work on executors. Executors are processes running on worker nodes. Each executor has its own CPU cores and memory allocation and operates on one or more data partitions.

Spark's fault-tolerance model treats executors as replaceable data-processing resources whose state can often be reconstructed through lineage: if an executor fails, its work is reassigned to another executor and computation continues. The driver, however, remains the central coordinator for the lifetime of the application. If the driver crashes, executors receive no further work and cannot report results, so execution halts as soon as the executors finish their currently assigned tasks; recovering requires an external mechanism to restart the driver. We also observed the driver hang under memory pressure without crashing outright — a second failure mode with the same halting effect, but one that lacks the clear process-exit signal of a crash and so may go undetected for longer. We confirmed this failure mode directly, on independent runs across both of our compute backends; see the appendix for the full classification. Both failure modes underscore why the driver should not be placed under the same memory and computational pressure as executors. Table I itemizes what is actually lost when the driver crashes or hangs without deliberate checkpointing.

Unfortunately, some Spark operations do exactly this.

In this paper, we focus on tree aggregation, a distributed computation pattern in which partition-local intermediate

*Corresponding author.

This is the extended version of a paper submitted for peer review. This work has been submitted to the IEEE for possible publication. Copyright may be transferred without notice, after which this version may no longer be accessible. Please cite the published conference version of this work once available, unless referring to material that appears only in this extended version.

TABLE I: State lost when the Spark driver crashes or hangs without intentional checkpointing. Executor failures are recoverable because lost partitions are reconstructed from lineage on another worker; the driver has no equivalent fallback, since it is the sole holder of the rows marked “Yes” below.

ComponentLocation / ownerLost on driver failure?
Consequence
RDD lineage DAGDriver JVMYesLineage must be reconstructed; lost RDD dependency graph.
DAGScheduler stateDriver JVMYesCannot resume jobs, stages, or dependencies.
Task completion stateDriver JVMYesCompleted tasks are not known to the new driver.
Shuffle map output trackingDriver JVMYesShuffle locations may be lost; stages may rerun.
Accumulator stateDriver JVMYesApplication metrics and counters may be lost.
Cached RDD partitionsExecutorsMaybeData may remain, but reuse is not guaranteed.
Shuffle data filesExecutors / shuffle serviceMaybeData may survive, but metadata may be unavailable.
Input dataExternal storageNoCan be reread to recompute results.
Checkpointed RDD dataReliable storageNoProvides a recovery point and limits recomputation.

states are recursively merged through an aggregation tree until a final aggregate is produced.

This pattern maps naturally onto shared-nothing systems. Workers compute locally, aggregate, and return the result to the coordination layer represented by the driver.

Spark provides tree aggregation primitives such as treeReduce and treeAggregate. Before SPARK-36419 [2] was included in v3.3.0, the root of the aggregation tree was placed on the driver rather than an executor. Even after this change, Spark by default still places the root of the aggregation tree on the driver. Only when finalAggregateOnExecutor is set to true does Spark move the root. Even when true, Spark continues to return a result of the same type as the intermediate aggregated state.

For algorithms that construct mergeable sketches, such as GK Sketch [3], Misra-Gries [4], or Count-Min Sketch [5], the final aggregation state may be a hash table, a 2-D array, a vector— possibly with supporting data structures. For such algorithms, the requested answer can be much smaller than the aggregation state. Spark nevertheless returns the full state to the driver, where the final answer is computed.

TreeRedux demonstrates the advantages of avoiding materializing the final aggregation state on the driver. It removes a source of driver hangs and crashes, and we show that it can improve asymptotic complexity as well as practical performance for two illustrative use cases.