Can a data platform keep its PySpark code and swap the engine underneath it? And what does that swap cost beyond wall time? I tested this on one machine with four engines, four storage conditions and a hard memory cap. Every result was hashed and every number below can be traced to a file in the public repository. This post is the full version of the study, not a summary. It follows the structure of the paper (PDF) and keeps its tables, models and source locations.
TL;DR
- Setup. One node with 8 vCPU and a 9 GiB cgroup memory cap. TPC-H at SF30 (22 queries) and a six-step DataFrame ETL set ran on Apache Spark 4.1.3 and 4.2.0, Apache DataFusion Comet 1.2.0, Sail 0.7.3 and DuckDB 2.0.1. Four storage conditions: local files, MinIO loopback, and MinIO behind a proxy with 0 ms and 10 ms of added latency. Runs used a seeded random order and per-query result hashing.
- Correctness of the benchmark itself. All 22 TPC-H results agreed across engines, stream types and conditions, after normalizing values to two decimals.
- Speed. Relative to Spark 4.2.0 on loopback object storage, total TPC-H time was 0.164 for Sail (95% CI 0.129 to 0.207), 0.126 for DuckDB (0.114 to 0.139) and 0.640 for Comet (0.548 to 0.747). Sail and DuckDB were faster on all 22 queries, and the two runs were fully separated on all 22.
- Statistics, honestly. With two repetitions per cell, run-level rank tests cannot reach significance (the minimum exact two-sided Mann-Whitney p is 1/3). The intervals above rest on an engine-level noise model. I say which conclusions depend on it.
- Object storage. The S3A Analytics Accelerator Library (AAL) cut GET requests by 54.6% on Spark 4.2.0. It saved time only with added latency (ratio 0.758 at +10 ms). On Spark 4.1.3 it was slower on loopback (1.176, CI 1.087 to 1.272). A two-point interpolation puts the AAL break-even at -0.06 ms of added latency on Spark 4.2.0 (95% interval -1.9 to 1.3 ms) and 2.5 ms on Spark 4.1.3 (-3.5 to 6.7 ms).
- The real cost of the swap is in edge cases. Examples: stale time zone data (one hour wrong in four probed zones on Sail; 23 of 70 probe rows in five of seven zones on Comet). A double-to-decimal cast was one cent off on 631 of 683,346 rows, and a binary64 model reproduces those 631 rows exactly. Further cases: decimal formatting through binary64, parsing gaps, a failing JSON permissive read, an empty write that loses the schema, table-format gaps and memory behavior.
What this means for your platform: a faster engine is easy to find. A faster engine that returns the same money and the same local time, on your table format, inside your memory limit, is the actual decision.
1. The question and the research questions
Most platforms that run Apache Spark do not need distributed execution for most jobs. Many jobs read a few to a few hundred gigabytes of Parquet, transform it and write it back. For those jobs, a single-node engine that speaks the same API or the same SQL is attractive: faster, cheaper and simpler to run. Three projects make this concrete today:
- Apache DataFusion Comet is a Spark plugin that runs supported operators natively [22].
- Sail implements the Spark Connect protocol on a Rust engine, so a PySpark client can talk to it unchanged [21].
- DuckDB is an embedded analytical database that runs the same SQL [5].
An architect has to answer not only "how much faster" but "what else changes". I split that into four research questions:
- RQ1 (speed). With identical job code (Comet, Sail) or identical SQL text (DuckDB), how does wall time compare to Spark on the same node, memory cap and data? How certain are we, given the number of repetitions?
- RQ2 (object storage). How does the S3A input stream (classic versus AAL) interact with request latency, and at what latency does AAL start to pay off?
- RQ3 (correctness). Where do results diverge from Spark, why, and can the divergence be predicted from first principles?
- RQ4 (operations and cost). What do table-format support, memory behavior and pricing imply for an engine choice on a customer platform?
The study contributes:
- a hash-verified comparison under a fixed memory cap with seeded randomized order, with its protocol deviations documented;
- a statistical treatment that separates what two repetitions can and cannot support, with engine-specific noise;
- a two-point latency interpolation with a break-even latency for AAL;
- a binary64 model of a measured double-to-decimal discrepancy, checked row by row against archived engine outputs;
- root causes with source locations and CI tests;
- a symbolic cost model.
2. Background and related work
This section places the study among existing benchmarks and explains the pieces (engines, S3A, floating point, time zones) that the results depend on.
Benchmarks. TPC-H is a decision-support benchmark of 22 queries over a generated schema [1]. Its choke points are analyzed in [2]. I use TPC-H as a workload, with cross-engine agreement as the result oracle. These are not audited TPC results or TPC-H metrics, and the data come from tpchgen-cli [26], not the official dbgen. Public engine comparisons such as ClickBench [29] and the DuckDB Labs db-benchmark [30] compare many engines on fixed workloads. They do not hold the job code constant or test semantic edge cases, and that is the focus here. Comet publishes its own TPC-H benchmarking guide [22].
Single-node engine studies. Two recent studies are the closest to this one. Mozzillo et al. [35] evaluate Python dataframe libraries for data preparation on a single machine, including the 22 TPC-H queries at SF10. Polars was the fastest CPU-only library, DuckDB (reported as a SQL reference point) was close to Polars, and Spark SQL trailed both overall, although it was faster than Polars on Q6. Szőke [36] reviews SQL-on-Hadoop and lakehouse engines and benchmarks 11 of them on one node (4 cores, 8 threads) at TPC-H SF1 and SF10. There, native and vectorized engines such as DuckDB, ClickHouse, Impala and Velox-accelerated Presto ran substantially faster than JVM-only stacks such as Spark SQL and Trino. My SF30 results point the same way (on loopback storage, DuckDB took 0.126 and Sail 0.164 of Spark 4.2.0's total time), but hardware, versions and settings differ, so only the direction is comparable, not the magnitudes. Both studies measure speed at scale factors up to 10. This study instead keeps the PySpark job code unchanged while swapping the engine underneath it (Sail through Spark Connect, Comet as a plugin), verifies results row by row and traces the differences to their IEEE 754 mechanism, and adds object-store latency with the S3A AAL stream, a cost model, and runs at SF30 and SF100.
Engines. Spark SQL introduced the DataFrame API and the Catalyst optimizer on top of Spark's RDD model [3, 4]. DuckDB is an embedded, vectorized analytical database [5], motivated as an in-process engine for data science [6]. Apache DataFusion is a modular Rust query engine on Apache Arrow [7], and both Comet and Sail build on it [21, 22]. Delta Lake adds ACID tables to object storage [8]. Durner, Leis and Neumann study how analytical engines should use cloud object storage, including request concurrency [9]. Spark reads object storage through Hadoop's S3A connector, which in Hadoop 3.4 and 3.5 can use the AWS Analytics Accelerator Library as its input stream [23, 24].
Floating point. IEEE 754 binary64 [10] cannot represent most decimal fractions exactly. Goldberg's survey explains what that means for rounding [11]. Since JDK 19, Double.toString returns the shortest decimal that round-trips (JDK-4511638) [28].
Time zones. Rust engines resolve zones with chrono-tz [27], which embeds a specific IANA tz database release [31]. The JVM ships its own tzdb.
Benchmark methodology and statistics. Hoefler and Belli list rules for reporting performance results, including variability and the number of runs [12]. Kalibera and Jones show how to choose repetitions at each level of a benchmark experiment [13]. I use Cliff's delta as an ordinal effect size [14] and Holm's step-down procedure for multiple comparisons [15].
3. Methodology
A benchmark is only as good as its controls. This section covers the machine, the pinned versions, how each engine was driven, how results were verified, how the statistics work, and where the protocol was not followed.
3.1 Environment and pinned versions
One Linux VM (kernel 6.12) had 8 vCPU reported as "Intel(R) Xeon(R) Processor" (the hypervisor does not expose the CPU model), 16 GB RAM and virtio block devices (device type not exposed). One benchmark ran at a time. Every job's process tree ran in a cgroup v2 group with memory.max = 9G (9 GiB) and swap off.
Engine settings inside the cap:
- Spark:
local[8]with a 6 GB driver. - Comet: 2 GB heap plus 3 GB off-heap, with
MALLOC_ARENA_MAX=2. - DuckDB:
memory_limit = 7GB, 8 threads, external file cache off. - Sail: defaults (no comparable memory setting).
The OS page cache was not dropped between runs.
| Component | Version |
|---|---|
| Apache Spark | 4.1.3 (hadoop-client 3.4.2), 4.2.0 (hadoop-client 3.5.0) |
| S3A + AAL | 4.1.3: hadoop-aws 3.4.2, SDK 2.29.52, AAL 1.2.1; 4.2.0: hadoop-aws 3.5.0, SDK 2.35.4, AAL 1.3.1 [23, 24] |
| Comet | 1.2.0 (comet-spark-spark4.2_2.13) [22] |
| Sail | pysail 0.7.3 (2026-10-30), pyspark-client 4.2.0 [21] |
| DuckDB | 2.0.1 |
| JDK | Temurin 21.0.13.1 (tzdata 2026f) |
| MinIO | source build, RELEASE.2025-10-15T17-29-55Z [25] |
| toxiproxy | 2.13.0 [32] |
| Generator | tpchgen-cli 4.0.0 (SF30: 24 parts per table, 12 GB) [26] |
Jar checksums, the MinIO tag, cgroup and engine settings are in VERSIONS.md in the repository.
3.2 Design
Factors.
- Engine configuration: 12 TPC-H configurations, including Spark and Comet with classic and AAL streams, and Sail with join reorder on and off.
- Storage condition: local file; MinIO loopback; toxiproxy with 0 ms; toxiproxy with 10 ms added to every response.
- Workload: the 22 TPC-H queries and ETL steps E1 to E6.
The proxy at 0 ms is the control for the proxy's own overhead, so the latency effect is the proxy10 minus proxy0 contrast.
How engines were driven. Spark and Comet ran one PySpark file (bench2_spark_api.py) with spark-submit; Comet adds only plugin configuration. Sail ran the same file with a Spark Connect URL. Sail's join reordering is a server setting, not job code. DuckDB ran the same TPC-H SQL text through its Python API, and the ETL steps as equivalent SQL. DuckDB's experimental PySpark API was not tested.
"Same SQL" means the same text, not the same semantics. In the ETL upsert, 1.1 is a DECIMAL literal in DuckDB, so DuckDB computes the price in exact decimal arithmetic, while PySpark's F.lit(1.1) is a double (Section 6.1). The "same code" claim holds for Comet and Sail; the "same SQL text" claim holds for DuckDB.
Repetitions and randomization.
- Fresh process. Each repetition starts a fresh process per configuration, with an untimed warmup (Q1, Q6, Q3 on SF1).
-
Seeded order. Configuration order was shuffled per repetition with
random.Random(1000 + rep). - Repetitions. Three were planned and two were analyzed (Section 3.5).
- Freeze detection. A sampler recorded process-tree RSS. A sampler gap overlapping a timed query marked the attempt frozen, and it was rerun (up to 3 attempts). The rule was refined during the matrix (Section 3.5).
Extensions.
- AAL isolation: 13 variant and condition cells on Spark 4.1.3 and 4.2.0 (Q1, Q3, Q6, Q9), with 2 to 3 valid repetitions.
- Table formats: Iceberg (written by Spark 4.1.3, Iceberg 1.12.0) and Delta (written by Spark 4.2.0, delta-spark 4.4.1) at SF30 with Q1, Q3, Q6, Q12 and Q18, two repetitions.
- Scale: SF100 (600,037,902 lineitem rows, 39 GB), local file, the same five queries, two repetitions, four engines.
The code that ran
The point of the study is that the job code does not change. Here is what that looks like in the harness. Every snippet below is a shortened but faithful excerpt; ... marks lines left out, and each block links to the full file.
One PySpark file for Spark, Comet and Sail (scripts/bench2_spark_api.py). The only engine-specific line is how the session is created: --remote turns the same script into a Spark Connect client for Sail.
from pyspark.sql import SparkSession, functions as F, Window
spark = SparkSession.builder.remote(a.remote).getOrCreate() if a.remote else SparkSession.builder.getOrCreate()
def register(base):
for t in TABLES:
path = f"{base}/{t}"
if a.format == "parquet":
# glob *.parquet so host snapshot sidecars (*.parquet.box-store-snap-*) are not opened as data files
spark.read.parquet(f"{path}/*.parquet").createOrReplaceTempView(t)
elif a.format == "iceberg":
spark.read.format("iceberg").load(path).createOrReplaceTempView(t)
else:
spark.read.format("delta").load(path).createOrReplaceTempView(t)
def run_sql_query(q):
df = None
for st in load_statements(a.qdir, q):
if is_ddl(st): spark.sql(st).collect()
else: df = spark.sql(st); rows = [tuple(r) for r in df.collect()]
return df, rows
...
# ETL step E6, the upsert behind finding F1
upd = (od95.filter(F.col("o_orderkey") % 10 == 0).select("o_orderkey", "o_custkey", F.lit("U").alias("o_orderstatus"),
(F.col("o_totalprice") * F.lit(1.1)).cast("decimal(15,2)").alias("o_totalprice"), "o_orderdate"))
base = od95.select("o_orderkey", "o_custkey", "o_orderstatus", "o_totalprice", "o_orderdate")
yield "E6_upsert_antijoin_union", base.join(upd.select("o_orderkey"), "o_orderkey", "left_anti").unionByName(upd), None
How each engine was launched (scripts/run_engine2.sh). Spark and Comet differ only in spark-submit flags; Sail gets a server process and the same script with --remote. Credentials come from environment variables only.
S3A="--conf spark.hadoop.fs.s3a.endpoint=http://127.0.0.1:$S3_PORT --conf spark.hadoop.fs.s3a.path.style.access=true
--conf spark.hadoop.fs.s3a.access.key=${BENCH_S3_KEY:?export BENCH_S3_KEY} --conf spark.hadoop.fs.s3a.secret.key=${BENCH_S3_SECRET:?export BENCH_S3_SECRET}
... --conf spark.sql.session.timeZone=UTC --conf spark.local.dir=$JOBTMP ..."
case $CFG in
spark*) $RUN -- $SH/bin/spark-submit --master 'local[8]' --driver-memory 6g $S3A $STREAM ... $ROOT/scripts/bench2_spark_api.py $COMMON;;
comet*) export MALLOC_ARENA_MAX=${COMET_MALLOC_ARENA_MAX:-2} # default glibc arenas OOM at 9 GiB (F2)
$RUN -- $SH/bin/spark-submit --master 'local[8]' --driver-memory ${COMET_HEAP:-2g} $S3A $STREAM \
--jars $CJARS --conf spark.driver.extraClassPath=$CPATH --conf spark.executor.extraClassPath=$CPATH \
--conf spark.plugins=org.apache.spark.CometPlugin \
--conf spark.shuffle.manager=org.apache.spark.sql.comet.execution.shuffle.CometShuffleManager \
--conf spark.comet.shuffle.enabled=true --conf spark.memory.offHeap.enabled=true \
--conf spark.memory.offHeap.size=${COMET_OFFHEAP:-3g} \
--conf spark.comet.explain.fallback.enabled=true $ROOT/scripts/bench2_spark_api.py $COMMON;;
sail-*) export AWS_ACCESS_KEY_ID=${BENCH_S3_KEY:?export BENCH_S3_KEY} AWS_SECRET_ACCESS_KEY=${BENCH_S3_SECRET:?export BENCH_S3_SECRET} \
AWS_ENDPOINT=http://127.0.0.1:$S3_PORT AWS_REGION=us-east-1 AWS_ALLOW_HTTP=true
[ $CFG = sail-reorder ] && export SAIL_OPTIMIZER__ENABLE_JOIN_REORDER=true || export SAIL_OPTIMIZER__ENABLE_JOIN_REORDER=false
$RUN --server "$ROOT/venv-sail/bin/sail spark server --port 50051" --server-wait-port 50051 -- \
$ROOT/venv-sail/bin/python $ROOT/scripts/bench2_spark_api.py --remote sc://127.0.0.1:50051 $COMMON;;
duckdb) $RUN -- $ROOT/venv-sail/bin/python $ROOT/scripts/bench2_duckdb.py $COMMON;;
esac
DuckDB runs the same SQL files (scripts/bench2_duckdb.py). The views have the same names as the Spark temp views, so the 22 query files are shared byte for byte.
con.execute("SET threads=8"); con.execute(f"SET memory_limit='{a.memory_limit}'") # 7GB
con.execute("SET enable_external_file_cache=false") # otherwise a later query reads from cache (Q6 had 0 GETs in the pilot)
con.execute("LOAD httpfs")
con.execute(f"CREATE SECRET minio (TYPE s3, KEY_ID '{os.environ['BENCH_S3_KEY']}', SECRET '{os.environ['BENCH_S3_SECRET']}', "
f"ENDPOINT '127.0.0.1:{port}', URL_STYLE 'path', USE_SSL false, REGION 'us-east-1')")
def register(base):
for t in TABLES:
path = f"{p(base)}/{t}"
if a.format == "parquet":
con.execute(f"CREATE OR REPLACE VIEW {t} AS SELECT * FROM read_parquet('{path}/*.parquet')")
...
Added latency with toxiproxy (scripts/orchestrate.py). The kernel on the box had no sch_netem, so tc netem was not an option. A TCP proxy on port 9100 forwards to MinIO on 9000, and the orchestrator sets the toxic before every job: none for proxy0, 10 ms downstream latency for proxy10.
def toxi(*args): return subprocess.run([f"{ROOT}/opt/bin/toxiproxy-cli", *args], capture_output=True, text=True)
def ensure_toxiproxy():
...
toxi("create", "-l", "127.0.0.1:9100", "-u", "127.0.0.1:9000", "minio_lat")
def set_latency(ms):
toxi("toxic", "remove", "-n", "lat", "minio_lat")
if ms: toxi("toxic", "add", "-n", "lat", "-t", "latency", "-a", f"latency={ms}", "-d", "minio_lat")
lst = toxi("inspect", "minio_lat").stdout
return lst.strip().replace("\n", " ")[:300] # stored with every attempt in state.jsonl
...
tox = set_latency(10 if j["cond"] == "proxy10" else 0)
The S3A stream switch and the AAL knobs. In Phase 2 the stream is one Hadoop key, chosen by the configuration name. The AAL isolation study added one extra key per variant (from results/aal-iso/plan.json):
case $CFG in
*-classic) STREAM="--conf spark.hadoop.fs.s3a.input.stream.type=classic";;
*-analytics) STREAM="--conf spark.hadoop.fs.s3a.input.stream.type=analytics";;
*) STREAM="";;
esac
# AAL isolation variants (EXTRA_CONF), Spark 4.2.0 with the analytics stream:
# G spark.hadoop.fs.s3a.analytics.accelerator.logicalio.prefetching.mode=off
# C spark.hadoop.fs.s3a.analytics.accelerator.physicalio.request.coalesce=false
# D spark.hadoop.fs.s3a.analytics.accelerator.physicalio.request.coalesce.tolerance=131072
# F spark.hadoop.fs.s3a.analytics.accelerator.logicalio.prefetch.page.index.enabled=false
# E spark.hadoop.parquet.hadoop.vectored.io.enabled=false
The 9 GiB cap (scripts/resume_after_restore.sh, scripts/run_one.py). The box had no systemd, so systemd-run --scope -p MemoryMax= was not available. The harness writes the cgroup v2 files directly and moves the runner into the group before it starts the engine, so every child (JVM, Sail server, DuckDB) inherits the cap.
CG=/sys/fs/cgroup/engine-swap-bench
[ -d $CG ] || { sudo -n mkdir -p $CG; echo 9G | sudo -n tee $CG/memory.max >/dev/null; echo 0 | sudo -n tee $CG/memory.swap.max >/dev/null; }
if a.cgroup:
subprocess.run(["sudo", "sh", "-c", f"echo 0 > {a.cgroup}/memory.peak 2>/dev/null; echo {os.getpid()} > {a.cgroup}/cgroup.procs"], check=True)
oom0 = cg_read("memory.events") # compared after the run to count oom_kill events
...
def sampler(): # process-tree RSS every 0.2 s (also the freeze detector's clock)
with open(a.rss_out, "w") as f:
f.write("t,rss_bytes\n")
while not stop:
tot = 0
for p in me.children(recursive=True):
try: tot += p.memory_info().rss
except psutil.Error: pass
peak[0] = max(peak[0], tot)
f.write(f"{time.time():.3f},{tot}\n"); f.flush()
time.sleep(0.2)
3.3 Hash verification
Every query result was hashed with an order-free hash_set, with values normalized to two decimals, and compared across configurations. Agreement therefore means agreement after that normalization, and the oracle is cross-engine agreement, not the official TPC-H answer set. ETL outputs were checked by DuckDB for row count, types and an order-free digest. This is also why the one-cent F1 difference in Section 6 does not appear in the TPC-H hashes: it lives in the ETL upsert, not in a TPC-H query.
What this means for your platform: a result hash per query is the cheapest correctness gate you can add to an engine migration. Put the normalization rule (here, two decimals) in writing, because it defines what "same result" means.
The normalization is in scripts/common.py. Every value becomes a string, floats and decimals both go through f"{f:.2f}", and the order-free hash sorts the normalized rows before hashing:
def norm(v):
if v is None: return "NULL"
if isinstance(v, bool): return str(v)
if isinstance(v, (int,)): return str(v)
if isinstance(v, (float, decimal.Decimal)):
f = float(v)
if math.isnan(f): return "NaN"
return f"{f:.2f}"
if isinstance(v, (datetime.date, datetime.datetime)): return v.isoformat()[:10] if isinstance(v, datetime.date) and not isinstance(v, datetime.datetime) else v.isoformat()
return str(v).rstrip()
def result_hashes(rows):
"""rows: list of tuples. Returns ordered hash, unordered hash, normalized rows."""
nrows = ["|".join(norm(x) for x in r) for r in rows]
h_ord = hashlib.sha256("\n".join(nrows).encode()).hexdigest()[:16]
h_set = hashlib.sha256("\n".join(sorted(nrows)).encode()).hexdigest()[:16]
return h_ord, h_set, nrows
Two design choices matter. Converting DECIMAL to float before formatting means a DECIMAL column on one engine and a DOUBLE column on another hash the same when the values agree to two decimals, and it is also why a one-cent difference would be visible but a difference in the third decimal would not. Sorting the normalized rows makes engines that return ties in a different order compare equal. The ordered hash is stored too, for queries where order is part of the answer.
3.4 Statistical analysis
With two repetitions per cell, the usual tests cannot reject anything. So the analysis separates what a noise model can support from what the raw runs alone can support. All scripts are in article/academic/analysis/ and read only the published result files (and, for F1, the archived engine outputs).
Per-cell intervals. I ran a percentile bootstrap (10,000 resamples) of the mean over repetitions for every query cell in all four studies (out/ci_per_query.csv). With
such an interval is at most the range of the two values. I report it for completeness, not as inference.
Totals: primary interval. For a configuration total
, I estimate the run-to-run variance of
separately per engine. Only that engine's SF30 TPC-H cells are pooled, and each cell with
contributes one degree of freedom (out/noise_by_engine_total.csv):
| Engine | SD of log total | Cells |
|---|---|---|
| Spark 4.2.0 | 0.022 | 7 |
| Spark 4.1.3 | 0.037 | 7 |
| DuckDB 2.0.1 | 0.052 | 4 |
| Comet 1.2.0 | 0.092 | 7 |
| Sail 0.7.3 | 0.144 | 8 |
The interval is Welch-type:
with from Welch-Satterthwaite. A single pooled over all 33 cells would be wrong here. The engine SDs differ by a factor of 6.6, so a pooled interval is too narrow for Sail and Comet and too wide for Spark-versus-Spark contrasts.
Totals: sensitivity. Two alternatives bracket the primary interval:
- Cell-only Welch interval. It uses each cell's own variance ( to 2) and is the most conservative choice.
- Stratified bootstrap. It resamples repetitions within each query and is anti-conservative, because query times within one session are correlated.
Studies outside SF30 Phase 2. For AAL isolation (4 queries, = 3 and 2) and SF100 (5 queries, ), I do not borrow the SF30 noise. I report only the range of repetition-total ratios:
Multiplicity. The 10 comparisons of Table 1 form one family. I report Holm-adjusted p values over all 10, with the two descriptive rows entering as untested ( ).
Rank tests. I used an exact two-sided Mann-Whitney U per query and on totals, with Cliff's delta and Holm correction across the queries of a comparison. For , the smallest attainable exact two-sided p is:
| n per side | Minimum exact two-sided p |
|---|---|
| 2 | 1/3 |
| 3 | 0.1 |
| 4 | 0.029 |
| 5 | 0.0079 |
Rejection at therefore needs for one test, with Holm across 4 queries, and with Holm across 22 queries. As a descriptive count that does support, I report how many queries are fully separated ( : both runs of A on the same side of both runs of B).
Query-level test. An exact Wilcoxon signed-rank test on over the queries. It has three limits:
- The 22 TPC-H queries are a fixed, designed set, not a random sample.
- Queries within a session are not independent.
- The test uses the per-query medians of two runs, so it ignores run noise.
I read it only as "for these 22 queries", and report the median per-query ratio and its range as the effect size.
The interval and the Holm step, as computed (article/academic/analysis/stats.py):
# engine variance of log(total): pool the n=2 cells of one engine, 1 df per cell
for (c, cfg), g in p2[p2.wl == "tpch"].groupby(["cond", "cfg"]):
t = np.log(g.groupby("rep").wall_s.sum().values)
if len(t) > 1: cellv.append(dict(cond=c, cfg=cfg, engine=ENG(cfg), var=t.var(ddof=1), dof=len(t) - 1))
CV = pd.DataFrame(cellv)
EV = CV.groupby("engine").apply(lambda d: pd.Series(dict(var=(d["var"] * d.dof).sum() / d.dof.sum(), dof=d.dof.sum(), cells=len(d))), include_groups=False)
...
# Welch-type interval on log(T_A / T_B), Welch-Satterthwaite df
lr_ = math.log(r["ratio"]); ea, eb = ENG(a), ENG(b); na, nb = r["reps_a"], r["reps_b"]
va, vb = EV.loc[ea, "var"] / na, EV.loc[eb, "var"] / nb
dfw = (va + vb) ** 2 / (va ** 2 / EV.loc[ea, "dof"] + vb ** 2 / EV.loc[eb, "dof"]); se = math.sqrt(va + vb); tc = stats.t.ppf(0.975, dfw)
row.update(strat_lo=math.exp(lr_ - tc * se), strat_hi=math.exp(lr_ + tc * se), strat_df=dfw, strat_p=2 * stats.t.sf(abs(lr_ / se), dfw))
...
# Holm across the family of 10 Table 1 comparisons; the two rows without a test enter as p = 1
T1["strat_p_holm10"] = multipletests(T1.strat_p.fillna(1.0).values, method="holm")[1]
The minimum exact Mann-Whitney p is one line, def min_exact_p(n1, n2): return 2 / math.comb(n1 + n2, n1), and it is the reason the table above has no "significant" per-query row.
3.5 Protocol deviations and survivorship
Real benchmark matrices do not run cleanly, and this one did not either. Only attempts that completed all queries without error and without a freeze are in the published tables. All attempts are in results/phase2/state.jsonl. The summaries below are in out/deviations.json, out/dev_attempts_by_engine.csv and out/dev_query_errors.csv.
| Engine (Phase 2, reps 1 to 3) | TPC-H attempts | ok | frozen | query error | timeout | failed | ETL attempts | ETL ok |
|---|---|---|---|---|---|---|---|---|
| Spark 4.2.0 | 28 | 16 | 6 | 4 | 2 | 0 | 9 | 8 |
| Spark 4.1.3 | 28 | 18 | 7 | 1 | 1 | 1 | 11 | 10 |
| Comet 1.2.0 | 24 | 18 | 1 | 1 | 0 | 4 | 12 | 11 |
| Sail 0.7.3 | 21 | 19 | 2 | 0 | 0 | 0 | 10 | 9 |
| DuckDB 2.0.1 | 8 | 8 | 0 | 0 | 0 | 0 | 5 | 5 |
In total there were 156 attempts: 122 ok, 19 frozen, 6 query error, 3 timeout and 6 failed. The failures include 3 Comet attempts that failed in 3 s because the jar was lost in the box restore, and one rep-3 attempt that I stopped.
Across all attempts there were 15 query errors, 12 of them on Spark:
-
Spark 4.2.0: 4
SparkOutOfMemoryError(UNABLE_TO_ACQUIRE_MEMORY), 2FAILED_READ_FILEand 2 follow-on errors from a stopped SparkContext. All were in two rep-3 attempts that were also frozen. -
Spark 4.1.3: 3
SparkOutOfMemoryErrorand 1 "No space left on device". - Sail: 2 server deaths at Q18 (OOM kill, local condition).
- Comet: 1 native allocation failure in a sort merge.
Several of these are properties of the engines under the cap, not of the harness, and the published tables condition on surviving them. A Spark cell that needed three attempts reports the time of the run that survived.
Deviations from the protocol.
-
Manual fourth attempt.
r2-loopback-spark420-analytics-tpchused up its 3 attempts (OOM at Q3, a freeze at Q8, OOM at Q12). After the AAL isolation study I ran a fourth attempt by hand (scripts/run_extra_r2_a4.py, 2026-11-26 00:25 Europe/Istanbul), outside the randomized schedule and about three days after the rest of the matrix. It is that cell's published rep 2. -
Order. The first attempts recorded in
progress.logstart in the seeded plan order (125 first starts, 0 order inversions). Retries did not keep their slot: 23 retries ran immediately after the failed attempt and 9 ran later. The orchestrator could also hold jobs: a disk-space gate for Spark and Comet TPC-H, and aCOMET_HOLDfile while the Comet memory setting was being fixed. In the recorded starts this paused the queue rather than reordering it, but the waiting time changed the box state between jobs. -
Box restore. On 2026-11-22 at about 01:41 Europe/Istanbul, the VM came back from a filesystem snapshot. Processes, the cgroup and
tmp/were lost and recreated, and 23 of the 102 published runs predate the restore. After the restore the memory balloon held about 10 GB, and a memory pump ran between jobs (untimed) to deflate it. - VM suspensions. Every sampler gap over 30 s coincided with the whole VM pausing (systemd watchdog messages). The freeze rule reran affected attempts; shorter pauses may remain in published runs.
- Freeze rule changed mid-matrix. At 2026-11-22 04:35 the rule changed from "gap > 2 s" to "gap > 2 s and (gap > 10 s or > 5% of the query's wall time)", because tool-call blips of 2 to 6 s were forcing full reruns. 45 of the 102 published runs started before the change.
-
Comet allocator.
MALLOC_ARENA_MAX=2was adopted on 2026-11-21 23:05 after Comet OOM kills with the default allocator. No published Comet run used the default allocator; earlier Comet attempts are superseded. - Rep 3 dropped. Rep 3 was stopped after 31 attempts, of which 12 were not ok (7 frozen, 3 timeouts, 1 query error, 1 stopped by me). For comparison, 13 of 65 attempts were not ok in rep 1 and 9 of 60 in rep 2. The recorded reason is "repeated Spark timeouts/stalls and query errors on rep 3". Those stalls and errors are partly outcomes of the engines under test, so dropping rep 3 was a decision informed by run outcomes (though not by the timings of completed runs). It was approved on 2026-11-23 09:01.
Sensitivity to rep 3. 12 TPC-H cells have a complete valid rep-3 run on disk. Adding them where they exist (out/dev_rep3_sensitivity.csv) changes the Table 1 ratios by at most 0.032 in absolute terms. The exception is Sail no-reorder local, where only the Sail side gains a rep 3 (0.128 to 0.153). The other changes:
| Comparison | Without rep 3 | With rep 3 |
|---|---|---|
| Sail loopback | 0.164 | 0.161 |
| Comet | 0.640 | 0.608 |
| Spark 4.2.0 AAL loopback | 1.009 | 1.014 |
| Spark 4.1.3 AAL loopback | 1.176 | 1.190 |
| DuckDB loopback | 0.126 | 0.125 |
No conclusion changes.
The same table as a picture. Spark 4.1.3 TPC-H is the only row with all four failure types, and DuckDB is the only engine where every attempt was ok.
The freeze rule that decided "frozen" is a few lines in scripts/orchestrate.py. It looks for gaps in the RSS sampler's timestamps (the sampler writes every 0.2 s, so a gap means the whole box stopped) and flags a query only if the gap overlaps it and is long enough to move its timing:
FREEZE_GAP = 2.0
def freeze_check(outdir):
ts = [float(x["t"]) for x in csv.DictReader(open(f"{outdir}/rss.csv"))]
gaps = [(a, b - a) for a, b in zip(ts, ts[1:]) if b - a > FREEZE_GAP]
flagged = []
for l in open(f"{outdir}/queries.jsonl"):
r = json.loads(l)
if r["event"] != "query": continue
for g0, g in gaps:
# flag only gaps that can move the timing: > FREEZE_GAP and (> 10 s or > 5% of the query's wall time)
if g0 < r["end"] and g0 + g > r["start"] and (g > 10 or g > 0.05 * r["wall_s"]): flagged.append({"q": r["q"], "gap_s": round(g, 1)})
return flagged
...
status = "frozen" if fl else ("timeout" if summ.get("timed_out") else (("qerror" if errs else "ok") if rc == 0 else "failed"))
What this means for your platform: when you run a proof of concept, log every attempt, not only the good ones. Here Spark had 12 of the 15 query errors under the same memory cap. With these settings, that is a finding about operating Spark at this size, not noise to clean away.
4. Results
This section answers RQ1 and RQ2 with the headline table, then covers table formats and the SF100 extension. All effect estimates are ratios of total wall time A/B over the common queries.
4.1 RQ1: speed
Table 1. Critical comparisons.
| Comparison (A vs B) | Ratio | 95% CI (engine-stratified Welch) or [min, max] | Holm p (10) | Faster / fully separated | Per-query ratio: median (range) |
|---|---|---|---|---|---|
| Sail reorder vs Spark 4.2, loopback | 0.164 | 0.129 to 0.207 | 4.0e-7 | 22/22 / 22 | 0.164 (0.096 to 0.347) |
| Sail no-reorder vs Spark 4.2, local | 0.128 | 0.101 to 0.162 | 1.6e-7 | 22/22 / 21 | 0.107 (0.063 to 0.833) |
| DuckDB vs Spark 4.2, loopback | 0.126 | 0.114 to 0.139 | 1.4e-7 | 22/22 / 22 | 0.153 (0.049 to 0.225) |
| DuckDB vs Spark 4.2, local | 0.125 | 0.113 to 0.139 | 1.4e-7 | 22/22 / 22 | 0.098 (0.027 to 0.502) |
| Comet vs Spark 4.2, loopback | 0.640 | 0.548 to 0.747 | 8.6e-4 | 21/22 / 18 | 0.702 (0.208 to 1.451) |
| Spark 4.2 AAL vs classic, proxy10 | 0.758 | 0.723 to 0.794 | 4.7e-8 | 22/22 / 22 | 0.747 (0.478 to 0.921) |
| Spark 4.2 AAL vs classic, loopback | 1.009 | 0.963 to 1.057 | 1.0 | 9/22 / 5 (2 slower) | 1.007 (0.808 to 1.338) |
| Spark 4.1.3 AAL vs classic, loopback | 1.176 | 1.087 to 1.272 | 0.0023 | 1/22 / 0 (15 slower) | 1.163 (0.951 to 1.624) |
| Spark 4.2 AAL vs classic, AAL isolation, proxy10 (Q1, Q3, Q6, Q9) | 0.828 | [0.786, 0.892] | not tested | 4/4 / 3 | 0.811 (0.571 to 0.915) |
| DuckDB vs Spark 4.2, SF100 (5 queries) | 0.171 | [0.109, 0.240] | not tested | 5/5 / 5 | 0.154 (0.122 to 0.295) |
"Fully separated" counts queries with
in the stated direction. For the 22-query rows where all 22 queries point the same way, the exact Wilcoxon p over these queries is 4.8e-7, the minimum attainable with 22 queries. It is 3.3e-5 for Comet, 3.3e-6 for Spark 4.1.3 AAL (slower) and 0.92 for Spark 4.2 AAL on loopback. Sources: out/table1_revised.csv and out/critical_perquery_tests.csv.
The heatmap shows where the totals come from. Sail and DuckDB are blue on every query in both storage conditions. Comet is mixed: Q11 is the one query where it was slower than Spark (1.45), and Q1 (0.21) and Q13 (0.35) gained most. AAL at +10 ms is blue on all 22 queries, while on loopback Spark 4.1.3 AAL is red almost everywhere, with Q12 (1.62) and Q15 (1.61) the slowest. The values are the per-query ratios in out/critical_perquery_tests.csv.
In the forest plot, blue is the primary engine-stratified Welch interval. Gray is the stratified bootstrap, which is anti-conservative because queries in one session are correlated. Red is the range of repetition-total ratios for the AAL isolation and SF100 rows, which have no interval.
Noise differs by engine. The pooled per-query log SD within a cell was:
| Engine | Pooled per-query log SD |
|---|---|
| Spark 4.1.3 | 0.08 |
| Spark 4.2.0 | 0.12 |
| Comet | 0.19 |
| Sail | 0.20 |
| DuckDB | 0.23 |
For Sail and DuckDB this fits their queries being short. Comet's queries are not short, so per-query noise is not explained by duration alone.
Comet AAL versus Comet classic works as a placebo. Comet's native scan does not use the S3A stream and the GET counts were identical. Yet the ratios were 1.026 (loopback), 0.965 (proxy0) and 0.948 (proxy10), so total-level differences of about 5% are within this setup's noise for Comet.
ETL and local files.
- ETL on loopback: Spark 4.2.0 took 115.5 s, Comet 73.0 s, DuckDB 23.1 s and Sail (no reorder) 19.6 s.
- Local TPC-H: DuckDB (48.41 s) and Sail no-reorder (49.58 s) took the same time within noise.
- Peak RSS: Sail had the highest (9.28 GB), against 7.41 GB for Spark 4.2.0, 5.44 GB for DuckDB and 4.88 GB for Comet.
What the statistics support. Under the engine-stratified noise model, these intervals all exclude 1 and survive Holm across the 10 comparisons:
- Sail, DuckDB and Comet against Spark 4.2.0;
- AAL at +10 ms on Spark 4.2.0;
- AAL on loopback on Spark 4.1.3.
The interval and the rank counts are two complementary analyses of the same runs, not independent evidence. The descriptive count that supports without a noise model is:
- Sail (loopback): fully separated on 22 of 22 queries.
- DuckDB: 22 of 22.
- Comet: 18 of 22.
- AAL at +10 ms: 22 of 22.
- AAL on Spark 4.1.3: 15 of 22 fully separated in the slower direction.
No per-query comparison survives Holm across 22 queries with , and none can. Under the most conservative cell-only Welch interval ( to 2):
- Still exclude 1: Sail (0.049 to 0.543), DuckDB (0.096 to 0.164) and AAL at +10 ms (0.627 to 0.916).
- Include 1: Comet (0.195 to 2.100) and Spark 4.1.3 AAL (0.932 to 1.483).
Spark 4.1.3 AAL is slower on loopback. A single variance pooled over all engines gave p = 0.071 at the total level, because the noisier Sail and Comet cells inflated it. With Spark 4.1.3's own run noise, AAL 1.2.1 on loopback is slower by an estimated 18% (95% CI 9% to 27%, Holm p = 0.0023), and 15 of 22 queries are slower in both runs. Only the cell-only interval, with one degree of freedom per side, includes 1. So the slowdown is supported, conditional on the engine-level noise model.
The claim "AAL saves no time on loopback for Spark 4.2.0" remains a failure to detect. The interval 0.963 to 1.057 is compatible with a 4% gain or a 6% loss.
What this means for your platform: the direction is not in doubt for Sail and DuckDB, since they won on every query in both runs. The size of the effect (6 to 8 times) rests on a noise model. If a business case depends on the exact multiplier, run more repetitions on your own data before you sign it.
4.2 RQ2: object storage and the S3A stream
The S3A input stream decides how Spark turns Parquet reads into HTTP requests. AAL is the newer stream from AWS; the question is when fewer requests turn into less wall time.
| Engine | GET reduction | Ratio loopback | Ratio proxy0 | Ratio proxy10 |
|---|---|---|---|---|
| Spark 4.2.0 (AAL 1.3.1) | 54.6% | 1.009 | 0.998 | 0.758 |
| Spark 4.1.3 (AAL 1.2.1) | 40.2% | 1.176 | 1.049 | 0.900 |
| Comet 1.2.0 | 0.0% | 1.026 | 0.965 | 0.948 |
AAL versus classic, TPC-H SF30 totals (ratio = AAL/classic).
Comet issued 64,252 GET requests for the TPC-H set, against 231,388 for Spark with the classic stream. Its count did not change with AAL, because its native scan does not use the S3A input stream. In AAL isolation at +10 ms, Q6 on Spark 4.2.0 fell from 22.52 s (classic, n=2) to 12.86 s (AAL, n=3). Section 5.1 models this.
Each point is one TPC-H query on one configuration (median of the repetitions). On loopback and at +0 ms, the AAL triangles sit to the left of the classic circles (fewer GETs) without moving down (no less time). At +10 ms, time starts to follow the GET count, which is exactly what the latency model in Section 5.1 formalizes. Sail and DuckDB issue fewer requests than Spark's classic stream on most queries and sit in the lower part of all three panels.
4.3 Table formats
All 85 Iceberg and Delta query results matched the Parquet hashes. Support was the finding, not speed.
-
Iceberg on Spark 4.2. Spark 4.2.0, and Comet on Spark 4.2.0, failed to load Iceberg with
java.lang.IncompatibleClassChangeError: Found interface org.apache.spark.sql.connector.catalog.CatalogManager, but class was expected. Noiceberg-spark-runtime-4.2artifact exists on Maven Central (HTTP 404 on 2026-11-26), and the 4.1 runtime is binary-incompatible. Spark 4.2 support is in progress upstream [16]. -
Delta on Comet. Comet on Spark 4.2.0 read Delta through a plain Spark
FileScan parquetoverPreparedDeltaFileIndex, with no Comet operators. Its five-query total (105.6 s, one valid run) equalled Spark's (105.9 s). Native Delta scanning in Comet is being built as a contrib module (#4700, #4952 and #5365, merged before the 1.2.0 release) rather than in core; the in-core PR #4669 is a draft that its reviewers propose to close [17]. The published 1.2.0 jar I used did not accelerate Delta, and I did not test a build with that module enabled. - Iceberg on Comet with Spark 4.1.3. Comet's native scan ran the five queries in 46.2 s.
- Five-query totals elsewhere: DuckDB 9.2 s (Delta) and 10.9 s (Iceberg); Sail 15.5 s and 19.1 s; Spark 100.8 s to 105.9 s.
What this means for your platform: check the table-format runtime for the exact Spark minor version before you plan an upgrade. On 2026-11-26, an Iceberg estate could not move to Spark 4.2.
4.4 SF100
At SF100 the data (39 GB) no longer fits in the page cache of a 16 GB machine, so this run tests behavior beyond it.
| Engine | Q1 | Q3 | Q6 | Q12 | Q18 | Total (s) |
|---|---|---|---|---|---|---|
| DuckDB 2.0.1 | 13.8 | 18.5 | 2.1 | 3.6 | 22.7 | 60.8 |
| Comet 1.2.0 | 21.2 | 44.7 | 7.1 | 18.3 | 77.1 | 168.4 |
| Spark 4.2.0 | 105.4 | 62.8 | 8.7 | 29.9 | 147.4 | 354.3 |
| Sail 0.7.3 (reorder) | 12.1 | 9.7 | 6.4 | 7.8 | OOM in 6 of 6 | none |
SF100 medians (s). The Sail Q1 to Q12 values are medians of 6 executions in sessions that later died on Q18.
DuckDB/Spark at SF100 is 0.171, and the four ratios of repetition totals range from 0.109 to 0.240. DuckDB's two SF100 runs took 81.1 s and 40.4 s, so this row carries much more run noise than the SF30 rows. With five queries, the exact query-level Wilcoxon p cannot be below 0.0625.
The whiskers make the DuckDB noise visible: its Q1 runs were 21.558 s and 6.086 s. Sail was the fastest engine on Q1 (12.1 s) and Q3 (9.7 s) at SF100 and then lost the whole session on Q18 in every attempt.
5. Models
Measurements tell you what happened at the conditions tested. Models tell you what to expect elsewhere and how far that expectation can be trusted. This section has three: request latency, scaling and cost.
5.1 Request-latency interpolation and AAL break-even
Let be the GET count of configuration over the TPC-H set and the added latency per response. Per configuration:
With three conditions and three parameters, this is exactly identified:
- is the loopback mean.
- is the proxy0 offset.
- is the slope between proxy0 and proxy10.
AAL ( ) beats classic ( ) when , that is for
where and are the proxy0 and proxy10 means of the totals. ParseError: KaTeX parse error: Expected group after '^' at position 2: L^̲ is therefore a **point estimate from a two-point linear interpolation. Linearity in is untested, because only 0 and 10 ms were measured, and the loopback condition does not enter ParseError: KaTeX parse error: Expected group after '^' at position 2: L^̲ .
The interval uses the Table 1 noise model. Each of the four means is simulated as the mean of two log-normal runs with the engine's
.
itself is drawn from its scaled inverse chi-square distribution (7 df), with 200,000 draws (out/models.json, latency_revised).
The quantity below is the summed added request latency divided by the added wall time:
I call it the model-implied latency-hiding factor: under the linear model, it is how many requests' worth of delay overlapped per second of wall time.
| Spark | Hiding factor classic | Hiding factor AAL | G classic | G AAL | Gap at proxy0 (s) | Gap at loopback (s) | Slope gap (s/ms) | L* (ms) | 95% interval |
|---|---|---|---|---|---|---|---|---|---|
| 4.2.0 | 11.2 | 28.3 | 231,388 | 105,264 | -1.06 | 3.90 | 16.9 | -0.06 | -1.9 to 1.3 |
| 4.1.3 | 10.2 | 10.2 | 231,388 | 138,104 | 22.68 | 76.36 | 9.22 | 2.46 | -3.5 to 6.7 |
AAL break-even on TPC-H SF30 totals. Gaps are AAL minus classic.
Spark 4.2.0. AAL issues 55% fewer requests, and its model-implied hiding factor is 28 versus 11. At proxy0 it is level with classic (ratio 0.998), and on loopback it is level within noise (1.009). Its advantage appears only once latency is added, and is indistinguishable from zero.
Spark 4.1.3 (AAL 1.2.1). The hiding factor does not change, so AAL can win only through fewer requests. It must first make up its deficit, which is 22.7 s at proxy0 and 76.4 s on loopback. The interpolated break-even, relative to the proxy0 baseline, is 2.5 ms. The 4.1.3 AAL fit has a proxy offset of -24.6 s, which has no physical meaning: run noise and session effects are of the same order as the effects being modeled.
Per query.
- Spark 4.2.0 AAL is ahead at proxy0 on 14 of 22 queries and at +10 ms on all 22.
- For Spark 4.1.3, 3 of 22 queries have no break-even (AAL never catches up under the linear model). The median break-even of the other 19 is 3.1 ms, and AAL is ahead at +10 ms on 21 of 22.
The same two-point picture for every engine configuration at proxy0 and proxy10:
| Configuration | Mean total, +0 ms (s) | Mean total, +10 ms (s) | Slope (s per ms) |
|---|---|---|---|
| Spark 4.2.0 classic | 495.9 | 702.0 | 20.6 |
| Spark 4.2.0 AAL | 494.8 | 532.1 | 3.7 |
| Spark 4.1.3 classic | 463.4 | 691.4 | 22.8 |
| Spark 4.1.3 AAL | 486.1 | 621.9 | 13.6 |
| Comet classic | 278.1 | 308.8 | 3.1 |
| Comet AAL setting | 268.3 | 292.9 | 2.5 |
| Sail reorder | 86.8 | 121.2 | 3.4 |
| Sail no reorder | 116.4 | 122.2 | 0.6 |
| DuckDB | 70.2 | 98.6 | 2.8 |
Source: out/devto_figs.json. Spark with the classic stream pays about 21 to 23 s of wall time per millisecond of added latency; AAL on Spark 4.2.0 cuts that to 3.7, close to the native engines. Comet's two rows are a placebo again: its native scan ignores the S3A stream setting. The Sail no-reorder slope is not interpretable, because its two proxy0 rep totals were 142.0 s and 90.9 s.
The break-even computation itself (article/academic/analysis/models.py) uses only the four proxy means, and the interval propagates the uncertainty in the engine noise as well as the noise itself:
A0, A10, C0, C10 = m[(f"{ver}-analytics", "proxy0")], m[(f"{ver}-analytics", "proxy10")], m[(f"{ver}-classic", "proxy0")], m[(f"{ver}-classic", "proxy10")]
gap0 = A0 - C0; slope = ((C10 - C0) - (A10 - A0)) / 10.0
Lstar = gap0 / slope if slope > 0 else np.nan
s2, dof = NE.loc[ver, "var"], NE.loc[ver, "dof"]
B = 200000
sig = np.sqrt(s2 * dof / rng.chisquare(dof, B)) # scaled inverse chi-square draw of sigma
def sim(mu, k): return mu * np.exp(rng.normal(0, 1, (B, k)) * sig[:, None]).mean(1) # mean of k log-normal runs
k = 2
a0, a10, c0, c10 = sim(A0, k), sim(A10, k), sim(C0, k), sim(C10, k)
sl = ((c10 - c0) - (a10 - a0)) / 10.0
Ls = np.where(sl > 0, (a0 - c0) / sl, np.nan)
...
Lstar_ci_ms=np.nanquantile(Ls, [0.025, 0.975]).tolist()
For context, AWS documents that for small requests (under 512 KB) "median latencies are often in the tens of milliseconds range". It describes S3 Express One Zone as designed for "single-digit millisecond latencies" [18]. The upper ends of both intervals (1.3 and 6.7 ms) are below the first figure. This is a plausibility comparison, not a prediction for S3. Here is a fixed delay that toxiproxy adds on top of loopback, while real latency is a distribution with a tail. The interpolation is also untested beyond 10 ms, and no real S3 endpoint was measured.
What this means for your platform: on Spark 4.2 with a real object store, AAL is the default to keep. On Spark 4.1.3, measure it on your storage path first, because without added latency it was 18% slower here.
5.2 Scaling with data size
I describe growth with data size by exponents
in
(out/scaling_fit.csv). These are descriptive, not fitted laws, because the points are not comparable conditions:
- SF10 is a single-run pilot on MinIO loopback, without the cap and with DuckDB's file cache on.
- SF30 times come from local files inside 22-query sessions.
- SF100 times come from local files in five-query sessions.
SF30 (12 GB) fits in the page cache of a 16 GB machine, at least partly, while SF100 (39 GB) does not, so the I/O regime changes between the two points. Q12 has no SF10 point. The SF30 to SF100 value is a two-point ratio with no estimable uncertainty:
| Engine | Least-squares slope over SF10, SF30, SF100 (Q1, Q3, Q6, Q18) | Two-point ratio SF30 to SF100 (5 queries): range, median |
|---|---|---|
| Spark 4.2.0 | 0.46 to 0.98 | 0.93 to 1.18, median 1.01 |
| Comet 1.2.0 | 0.70 to 1.07 | 0.94 to 1.14, median 1.02 |
| Sail 0.7.3 | 1.06 to 1.16 (Q1, Q3, Q6 only) | 0.69 to 1.62 (4 queries, no Q18), median 1.02 |
| DuckDB 2.0.1 | 1.18 to 1.71 | 0.40 to 1.96, median 1.20 |
Descriptive scaling exponents. Sail Q18 has no SF100 time. Its SF10 to SF30 ratio (0.33) compares an uncapped pilot with capped runs and is not used.
Between SF30 and SF100, Spark and Comet grew about in proportion to data size ( ). DuckDB was the most variable: Q18 grew 10.6 times for 3.33 times the data, while Q1 grew less than proportionally. DuckDB's two SF100 runs differed by up to 3.5 times on Q1, with no page-cache drop between them. Spark's SF10 to SF30 exponents below 1 may reflect fixed overhead in a short pilot.
Sail Q18 memory: observations, not an extrapolation (out/sail_q18_attempts.csv).
- SF10 pilot (no cap): process-tree peak RSS during Q18 was 3.87 GB.
- SF30, local files: Q18 was OOM-killed in 2 of 4 attempts with join reorder and 1 of 4 without.
- SF30, object store: all 14 Sail Q18 attempts completed (6 loopback, 4 proxy0, 4 proxy10). So the failure depends on the storage condition, not only on the scale factor.
- SF100: all 6 valid attempts were killed.
Session peak tree RSS was 8.13 to 9.54 GB for completed SF30 runs and 8.68 to 9.58 GB for killed attempts. Kills happened below the peak of some successful runs, so tree RSS sampled at intervals is not the quantity the kernel acts on. cgroup memory.peak was 9.66 to 9.67 GB in every attempt that wrote a summary, including successful ones, because it counts page cache. So it cannot separate the two outcomes either.
What an OOM kill looks like from the sampler, for two attempts of the same configuration on the same data:
Both runs climb the same way into Q18. The killed attempt's last sample is 9.45 GB; the completed one peaked at 9.15 GB and then released memory. The sampled RSS is the process tree only, while the kernel enforces the cap on the whole cgroup charge, so a sampled peak below the 9.66 GB line can still end in a kill. After the kill, the harness restarted the Sail server and ran Q19 to Q22, which is the red line after the gap.
What this means for your platform: a memory test on one storage path does not certify another. Test the heaviest join on the exact storage path and memory limit you will run in production.
5.3 Cost model
For a platform with hourly rate , per-run runtime and billed startup , the monthly cost of runs per day is
Rates are Azure West Europe, pay as you go, in USD, read on 2026-11-26 from the Azure Retail Prices API [33]. Meter IDs are also in article/cost_table.md.
| Item | Rate (USD) | meterId |
|---|---|---|
Standard_F8s_v2 Linux VM |
0.388 per hour | 86563e2c-da39-440f-8e8c-a1c94711b118 |
Standard_D8ds_v5 |
0.544 per hour | 2a477454-b363-5169-bcd6-bacac0dbabc1 |
| Databricks Premium Jobs Compute | 0.30 per DBU-hour | 8ee07b23-82ae-430e-a417-a050463ff4ee |
Fabric autoscale for Spark Capacity Usage CU
|
0.22 per CU-hour | dcc3f574-0e57-5d34-ab6c-1e70659f7da7 |
How the platform rates follow from these:
-
Databricks. The Azure Databricks pricing page lists 2.00 DBU/h for
D8ds v5[34], so USD per hour. - Fabric. 1 CU = 2 Spark vCores, so 8 vCores give USD per hour.
- Startup billing. Microsoft documents that Fabric does not bill cluster acquisition or Spark context initialization [19], so is not billed. Databricks classic Jobs Compute bills the VM and DBUs while the cluster is up, so is billed. There is no official number for , so I keep it symbolic.
Assumptions that matter.
-
Instance mapping is not uniform. The lab VM has 8 vCPU and 16 GB. I price DuckDB on
F8s_v2(8 vCPU, 16 GiB), the closest match, but Databricks onD8ds_v5(8 vCPU, 32 GiB), a series with a published DBU count. So the Databricks figure prices a larger machine than I measured. - Fabric at 8 vCores assumes a single-node session in which driver and executor share one 8-vCore node. A pool with a separate driver node and one executor node of the same size bills 16 vCores and doubles .
- Databricks Runtime and the Fabric Spark runtime are not open-source Spark 4.2.0. Photon and the Fabric native execution engine were not measured. I multiply open-source Spark wall times by list prices.
Per-run against per-run. Both sides are linear in , so there is no break-even in runs per day; the ratio is constant:
with s (Spark 4.2.0) and s (DuckDB).
- Base ratio. With , the ratio is 23.5 against Databricks and 18.0 against Fabric.
- Robust to price error. If each of the two rates were off by up to 50% in the unfavorable direction, the Databricks ratio would still be 7.8 (and 6.0 for Fabric). It is dominated by the 8-fold runtime ratio.
- Parity. It would need a billed VM boot of s against Databricks with zero startup, or 943 s against Fabric.
Per-run against always-on. If the DuckDB VM runs all month ( = 279.36 USD), the break-even is
| s_D (s) | Databricks USD/run | N* vs always-on VM | Fabric USD/run | N* vs always-on VM |
|---|---|---|---|---|
| 0 | 0.1398 | 66.6 | 0.1076 | 86.6 |
| 60 | 0.1589 | 58.6 | 0.1076 | 86.6 |
| 180 | 0.1970 | 47.3 | 0.1076 | 86.6 |
| 300 | 0.2352 | 39.6 | 0.1076 | 86.6 |
| 600 | 0.3305 | 28.2 | 0.1076 | 86.6 |
Break-even runs per day between per-run managed Spark and an always-on DuckDB VM. The values are illustrative parameters, not measurements. An always-on VM can run at most DuckDB runs per day. The Fabric values assume the single-node session above. Storage, network, retries and egress are excluded.
The chart is the table drawn out. Below the marked points, paying per run for managed Spark is cheaper than keeping a DuckDB VM up all month; above them, the always-on VM wins. The per-run DuckDB VM line stays close to zero at every run count, which is where the base ratios of 23.5 and 18.0 above come from.
6. Correctness analysis: the IEEE 754 details
TPC-H in UTC exercises none of the following cases. Each was reproduced with a short script (7 to 20 lines plus a shared 14-line helper) that runs unchanged on Spark (spark-submit) and Sail (Spark Connect). The outputs were re-run on 2026-11-26. The F1 and C4 explanations below are verified mechanistic models. They rest on reading the source, on literal repros and, for F1, on a row-level match with the archived engine outputs. They are not proofs about every input.
6.1 F1: double to decimal, one cent on 631 rows
The ETL upsert computes (o_totalprice * F.lit(1.1)).cast("decimal(15,2)"), where o_totalprice is decimal(15,2) and the product is binary64. Sail returned one cent less than Spark on 631 of 683,346 updated rows.
Model. Spark computes
where
is the shortest decimal string that round-trips to
. Decimal(double) goes through Scala BigDecimal.decimal, that is Double.toString, then changePrecision with ROUND_HALF_UP. Shortest output is guaranteed only since JDK 19 (JDK-4511638) [28]. On JDK 17 and earlier, Double.toString can return a longer string for some values, so the Spark side of this model, and Spark's result on rare inputs, depends on the JDK (I ran JDK 21). Sail 0.7.3 computes
where
is binary64 rounding (arrow-cast (mul * input).round()).
Example. Take o_orderkey = 83620 with o_totalprice = 35246.95. Then
has the shortest form 38771.645, but its exact value is
and
Spark rounds 38771.645 half up to 38771.65. Sail rounds 3877164.49999... to 3877164, that is 38771.64.
You can check the binary values with Python's decimal module, which prints the exact value of a double:
from decimal import Decimal
x = 35246.95 * 1.1
print(repr(x)) # 38771.645 (shortest round-trip form)
print(Decimal(x)) # 38771.6449999999967985786497592926025390625
print(Decimal(100 * x)) # 3877164.4999999995343387126922607421875
print(Decimal(2.675), 100 * 2.675)
# 2.67499999999999982236431605997495353221893310546875 267.5
Row-level check. I applied both formulas to all 683,346 E6 rows of the SF30 data. That gives 631 mismatches, all one cent lower on the Sail side. I then compared the archived E6 outputs of the last Sail 0.7.3 and Spark 4.2.0 runs, which were still in the MinIO bucket, row by row. They differ on exactly 631 o_orderkey values, all by one cent in the predicted direction:
- Same set. The measured set and the model's set are identical: 631 rows in both, and 0 in only one of them.
- Same values. The predicted Spark and Sail values match the measured values on all 631 rows.
-
Files. The check is
analysis/f1_rows.py, the keys are inout/f1_mismatch_orderkeys.csvand the summary is inout/f1_rows.json.
The non-updated rows agree exactly. Comet 1.2.0, Spark 4.1.3 and DuckDB have 0 differences from Spark 4.2.0 on the updated rows. DuckDB agrees for a different reason: it parses 1.1 as a DECIMAL literal and computes the product exactly. Its result matches Spark on all 683,346 rows, although the arithmetic is not the same.
A third candidate model, half-up on the exact binary value, gives 8,089 mismatches and is rejected.
The literal 2.675 shows why the scaled form matters. Its exact value is 2.67499999999999982236431605997495353221893310546875, but exactly, so Sail returns 2.68, as measured.
Where the 631 rows sit. For every updated row I computed the exact value of
and its signed distance to the nearest half-cent tie
(article/academic/analysis/f1_drift.py, summary in out/f1_drift.json):
| Position of fl(100 x) relative to the tie | Rows | Sail vs Spark |
|---|---|---|
| Below the tie, within 1e-8 cents | 631 | Sail one cent lower on all 631 |
| Exactly on the tie | 34,748 | equal (both round up) |
| Above the tie, within 1e-8 cents | 32,951 | equal |
| 0.05 cents or more from a tie | 615,016 | equal |
The 631 rows are within 1.5e-11 to 3.7e-9 cents below a tie, and no other row is below a tie within that distance. That is the whole mechanism in one table: Spark's shortest decimal string turns all three near-tie groups into an exact .xx5, which rounds up; Sail rounds the binary value, which goes down only for the group below the tie.
The core of the check, from article/academic/analysis/f1_rows.py:
# model: Spark = shortest repr of binary64 product, HALF_UP; Sail = arrow-cast round(100*x) half away from zero
rows = con.execute(f"""select o_orderkey, cast(o_totalprice as varchar) from read_parquet('{ROOT}/data/tpch-sf30/orders/*.parquet')
where year(o_orderdate)=1995 and o_orderkey % 10 = 0""").fetchall()
q = Decimal("0.01"); pred = []
for k, p in rows:
x = float(Decimal(p)) * 1.1
spark = Decimal(repr(x)).quantize(q, ROUND_HALF_UP)
sail = Decimal(100.0 * x).quantize(Decimal(1), ROUND_HALF_UP).scaleb(-2)
if sail != spark: pred.append((k, p, str(spark), str(sail)))
...
mk = {r[0] for r in meas}; pk = {r[0] for r in pred}
res["set_intersection"] = len(mk & pk); res["only_measured"] = len(mk - pk); res["only_model"] = len(pk - mk)
Python's repr of a float is the shortest round-trip string, the same contract as Double.toString on JDK 19 and later, which is what makes this a faithful model of the Spark side.
6.2 C4: format_number on DECIMAL through binary64
Sail converts every input to binary64 and formats with Rust {:.N}, which rounds the exact binary value. Spark formats Decimal.toJavaBigDecimal with java.text.DecimalFormat, whose default rounding is HALF_EVEN, on the exact decimal. F1 and C4 share the step of converting a decimal value to binary64, but they round by different paths:
- F1: scale by 100 in binary64, then round half away from zero.
- C4: round the exact binary value at the requested digits.
So they are related, not the same root cause.
| Input decimal | Exact binary64 value | Spark (HALF_EVEN on decimal) | Sail (binary64) |
|---|---|---|---|
| 0.005 | 0.005000000000000000104083408558608425664715468883514404296875 | 0.00 | 0.01 |
| 1.115 | 1.1149999999999999911182158029987476766109466552734375 | 1.12 | 1.11 |
| 2.675 | 2.67499999999999982236431605997495353221893310546875 | 2.68 | 2.67 |
| 12345678901234567.89 | 12345678901234568 (ulp = 2) | 12,345,678,901,234,567.89 | 12,345,678,901,234,568.00 |
Each Sail value is the correct rounding of the exact binary value. Each Spark value is the HALF_EVEN rounding of the decimal.
The repro, as in the repository (repro/minimal/c4_sail_format_number_decimal.py):
from _common import session, show
spark, eng = session()
show(spark, "C4_format_number", """select
format_number(cast(0.005 as decimal(5,3)), 2) tie_half_even,
format_number(cast(1.115 as decimal(5,3)), 2) tie_binary_below,
format_number(cast(2.675 as decimal(5,3)), 2) tie_binary_below2,
format_number(cast('12345678901234567.89' as decimal(19,2)), 2) beyond_2_pow_53""")
spark.stop()
Cent resolution is lost well before
. From
on, the binary64 spacing is
, so distinct cent values collide: 70368744177664.01 and 70368744177664.02 map to the same binary64 value, 70368744177664.015625. Above
the spacing exceeds 1 and whole units are lost (out/ieee.json).
What this means for your platform: any path that sends money through a double can be off by a cent, and which engine looks "right" depends on its rounding path. Keep monetary columns DECIMAL end to end, including literals.
6.3 C1 and Comet time zones
Sail 0.7.3 and Comet 1.2.0 resolve zones with chrono-tz 0.10.4 [27], which embeds IANA tzdata 2025b [31]. Spark uses the JVM tzdb (2026f on Temurin 21.0.13.1). Zones whose rules changed after 2025b differ by one hour:
from_utc_timestamp input |
Spark 4.2.0 | Sail 0.7.3 |
|---|---|---|
| 2026-11-21 18:00 UTC, America/Havana | 14:00 | 13:00 |
| 2027-01-15 18:00 UTC, America/Edmonton | 12:00 | 11:00 |
| 2027-01-15 18:00 UTC, America/Yellowknife | 12:00 | 11:00 |
| 2027-04-01 12:00 UTC, Africa/Casablanca | 12:00 | 13:00 |
| 2025-06-01 12:00 UTC, Europe/Istanbul (control) | 15:00 | 15:00 |
C1. No error or warning on Sail.
The probe (repro/minimal/c1_sail_stale_tzdata.py, first query):
from _common import session, show
spark, eng = session()
spark.conf.set("spark.sql.session.timeZone", "UTC")
show(spark, "C1_from_utc_timestamp", """select
cast(from_utc_timestamp(timestamp'2026-11-21 18:00:00', 'America/Havana') as string) havana,
cast(from_utc_timestamp(timestamp'2027-01-15 18:00:00', 'America/Edmonton') as string) edmonton,
cast(from_utc_timestamp(timestamp'2027-01-15 18:00:00', 'America/Yellowknife') as string) yellowknife,
cast(from_utc_timestamp(timestamp'2027-04-01 12:00:00', 'Africa/Casablanca') as string) casablanca,
cast(from_utc_timestamp(timestamp'2025-06-01 12:00:00', 'Europe/Istanbul') as string) control_istanbul""")
Comet logs Comet's native library uses timezone database 2025b, but the JVM uses 2026f. In its native projection with session zone America/Havana, it returned hour = 7 against Spark's 8 for the same Parquet timestamp. Across the Comet probe (results/probes/comet_tz_v2.jsonl, summarized in out/comet_tz_summary.json), 23 of 70 rows differed from Spark, in 5 of the 7 session zones:
| Session zone | Rows that differ from Spark |
|---|---|
| Africa/Casablanca | 6 |
| America/Havana | 5 |
| America/Edmonton | 5 |
| America/Yellowknife | 5 |
| Europe/Chisinau | 2 |
| America/Sao_Paulo | 0 |
| UTC | 0 |
Each zone had 10 probe rows. The zones that changed rules after tzdata 2025b lose between 2 and 6 of them; the controls (America/Sao_Paulo and UTC) lose none.
The probe (probes/comet_tz_probe.py) writes ten UTC instants around recent rule changes to Parquet, reads them back under each session zone, and records whether Comet's native projection ran:
zones = ["America/Havana", "America/Edmonton", "America/Yellowknife", "Africa/Casablanca", "Europe/Chisinau", "America/Sao_Paulo", "UTC"]
for z in zones:
spark.conf.set("spark.sql.session.timeZone", z)
df = spark.read.parquet(ddir).select("name",
F.col("ts").cast("string").alias("ts_str"), F.hour("ts").alias("hr"), F.col("ts").cast("date").cast("string").alias("dt"),
F.date_format("ts", "yyyy-MM-dd HH:mm XXX").alias("fmt"), F.date_trunc("day", "ts").cast("long").alias("trunc_day_epoch"),
F.from_utc_timestamp("ts", z).cast("long").alias("from_utc_epoch"), F.to_utc_timestamp("ts", z).cast("long").alias("to_utc_epoch"),
F.unix_timestamp("s").alias("unix_from_str"), F.to_timestamp("s").cast("long").alias("str_to_ts_epoch"),
F.col("ts").cast("timestamp_ntz").cast("string").alias("ltz_to_ntz"))
rows = df.collect()
try: plan = df._jdf.queryExecution().executedPlan().toString()
except Exception as e: plan = str(e)
native = "CometProject" in plan
...
It runs once on plain Spark 4.2.0 and once with the Comet plugin, appending to the same JSONL file (scripts/run_repros.sh):
$ROOT/opt/spark-4.2.0-bin-hadoop3/bin/spark-submit --master 'local[2]' $ROOT/probes/comet_tz_probe.py spark420 $P/comet_tz_v2.jsonl $ROOT/tmp/tzdata_pq
$ROOT/opt/spark-4.2.0-bin-hadoop3/bin/spark-submit --master 'local[2]' --jars $CJ --conf spark.driver.extraClassPath=$CJ --conf spark.plugins=org.apache.spark.CometPlugin \
--conf spark.shuffle.manager=org.apache.spark.sql.comet.execution.shuffle.CometShuffleManager \
--conf spark.memory.offHeap.enabled=true --conf spark.memory.offHeap.size=2g --conf spark.comet.explain.fallback.enabled=true \
$ROOT/probes/comet_tz_probe.py comet120 $P/comet_tz_v2.jsonl $ROOT/tmp/tzdata_pq
What this means for your platform: time zone data is a dependency with a release cycle, like any library. If your engine embeds its own tzdb, it belongs in your version pinning and your CI.
6.4 C7, C8 and C5
-
C7.
cast('1e3' as decimal(10,0)): Spark returns 1000. Sail returnsCannot cast string '1e3' to value of Decimal128(38, 10) type, andtry_castgives NULL on Sail, so a defensive cast loses data silently. -
C8.
spark.read.schema("k int, d decimal(5,2)").json(path)over rows12.5,99999999.99,"abc": Spark PERMISSIVE gives[(1, 12.50), (2, None), (3, None)]. Sail fails the read withParser error: parse decimal overflow (99999999.99). -
C5. Writing an empty DataFrame: Spark writes
_SUCCESSand a schema-only part file and reads backstruct<a:int,b:string,c:decimal(5,2)>with 0 rows. Sail writes no directory and reads backstruct<>.
7. Root causes, fixes, workarounds and CI tests
A divergence is manageable once you know where it comes from. For each case below: the source location, the fix (upstream or proposed), a workaround you can apply today, and a CI test that catches a regression. Source locations are at these tags or commits: Sail v0.7.3 and main dc60702 (2026-11-26), arrow-rs 59.2.0 (used by Sail 0.7.3) and 60.1.0, DataFusion 55.2.0, Spark v4.2.0, and Comet main f67d51d (2026-11-24). Upstream issue and PR numbers are listed in [20].
F1: double to decimal
-
Root cause. arrow-cast 59.2.0
cast/decimal.rs:770cast_floating_point_to_decimal,:819(mul * input).round()rounds . SparkCast.scala:1137changePrecision(Decimal(double)),Decimal.scala:590and:353(ROUND_HALF_UP) round the shortest decimal (JDK 19 or later). -
Fix. Sail PR #3024 adds a Spark-compatible
float_to_decimal(open) [20]. -
Workaround. Cast through string,
cast(cast(x as string) as decimal(p,s)), or keep money in DECIMAL end to end (a DECIMAL literal instead ofF.lit(1.1)). -
CI test. Column digest of
cast(double as decimal)on generated tiesk + 0.005against Spark.
C4: format_number
-
Root cause. Sail
format_number.rs:112format_number_fixed(value: f64),:117format!("{:.prec$}"),:234scalar_to_f64. - Fix. Format DECIMAL with an exact decimal type and HALF_EVEN.
- Workaround. Format in the serving layer, or round with DECIMAL arithmetic first.
- CI test. Golden strings for 0.005, 1.115, 2.675, a value just above and one above .
C1: Sail time zones
-
Root cause. Sail
Cargo.lock:1492(v0.7.3) and:1463(main) pinchrono-tz 0.10.4, which is tzdata 2025b (Cargo.toml:69). Spark usesjava.timezone rules from the JDK. - Fix. Bump chrono-tz with each tzdata release, or warn as Comet does.
- Workaround. Store UTC and convert at serving; avoid zones changed since 2025b.
-
CI test. Compare
from_utc_timestampfor canary zones (Havana, Edmonton, Yellowknife, Casablanca, Chisinau) against Spark; fail on drift.
Comet time zones
-
Root cause. Comet
native/Cargo.lock:1384chrono-tz 0.10.4. The warning is inNativeBase.java:176warnOnTzdataMismatch(from #6353), with the version vianative/core/src/lib.rs:290. - Fix. Known, #6331 (closed with warning) [20].
- Workaround. Same as C1, or disable native datetime expressions for affected zones.
- CI test. Fail CI on the startup warning text.
C7: exponent strings to DECIMAL
-
Root cause. Sail v0.7.3
correlation_cast.rs:522calls arrow-cast 59.2.0parse_string_to_decimal_native(cast/decimal.rs:534), which splits on.and does not parse exponents. -
Fix. On Sail main,
correlation_cast.rs:535now callsparse_decimal(arrow-cast 60.1.0parse.rs:896, exponent handling at:956-976) after PR #3107 (merged 2026-11-26) [20]. Not released, not re-tested. - Workaround. Cast via double for non-money columns, or normalize strings before casting.
-
CI test.
cast('1e3'),cast('1.5E2'),cast('-2e-2')withcastandtry_cast; assert no NULLs.
C8: JSON permissive read
-
Root cause. Sail
formats/json/read.rs:117builds a DataFusionJsonSourcewithout mapping Spark'smode. arrow-json 59.2.0reader/decimal_array.rs:94-97returns the parse error unlessignore_type_conflictsis set. -
Fix. Map PERMISSIVE to null-on-error per field, and support
columnNameOfCorruptRecord. -
Workaround. Read the column as string, then
try_cast(after C7 is fixed). - CI test. One overflowing and one non-numeric record per type; assert row count and NULLs.
C5: empty write
-
Root cause. DataFusion 55.2.0
datasource/src/write/demux.rs:179-192opens a file for empty input only whensingle_file_outputis set; otherwise no writer is created (:238). - Fix. Write a schema-only file for empty input, as Spark does.
- Workaround. Use downstream readers with an explicit schema, and check for a missing path.
- CI test. Write an empty DataFrame, read it back, assert schema equality.
Comet memory
-
Root cause. Native allocations go through glibc malloc, and per-thread arenas keep freed memory (
mallopt(3)M_ARENA_MAX), so RSS exceeds Comet's accounted pool. Known as #7108 [20]. - Fix. Upstream discussion: jemalloc as default (#7344), trimming the native heap [20].
-
Workaround.
MALLOC_ARENA_MAX=2. In diagnostic runs with the same 2 GB + 3 GB budget, peak tree RSS was 5.1 to 5.5 GB (three runs) against 8.1 and 9.5 GB with the default allocator (out/comet_mem_summary.json). The same diagnostics suggest a speed cost (Section 9). - CI test. Peak-RSS budget test on the heaviest query under the target cgroup.
Spark F4: execution memory
-
Root cause.
UnsafeExternalSorter.java:404growPointerArrayIfNecessary, thenMemoryConsumer.java:151throwOom, thenSparkCoreErrors.scala:451UNABLE_TO_ACQUIRE_MEMORYwhen execution memory in a 6 GB driver is exhausted. - Fix. Not a bug; a budget limit.
-
Workaround. Larger driver or executor memory,
spark.sql.shuffle.partitions, spill settings (not tested here). - CI test. Heaviest queries at production size, two consecutive passes, inside the production memory limit.
Items marked known should not be re-filed upstream.
A CI gate for the decimal and time zone cases can be small. The sketch below is not in the repository. It runs the same SQL on a Spark reference session and on the candidate engine (for Sail, a Spark Connect session) and fails on any difference:
CHECKS = {
# F1: binary64 product cast to DECIMAL (F1 model: Spark 38771.65, Sail 0.7.3 38771.64)
"f1_tie": "select cast(cast(35246.95 as double) * cast(1.1 as double) as decimal(15,2)) v",
# C4: format_number on DECIMAL (measured: Spark 2.68, Sail 2.67)
"c4_format": "select format_number(cast(2.675 as decimal(5,3)), 2) v",
# C1: tzdata drift (measured: Spark 14:00, Sail 13:00)
"c1_havana": "select cast(from_utc_timestamp(timestamp'2026-11-21 18:00:00', 'America/Havana') as string) v",
# C7: exponent string (measured: Spark 1000, Sail 0.7.3 NULL)
"c7_exponent": "select try_cast('1e3' as decimal(10,0)) v",
}
def test_engine_matches_spark(reference, candidate):
for name, sql in CHECKS.items():
ref = reference.sql(sql).collect()
got = candidate.sql(sql).collect()
assert ref == got, f"{name}: reference={ref} candidate={got}"
What this means for your platform: none of these cases shows up in a TPC-H hash. They show up as a one-cent reconciliation break, a report one hour off, or a NULL that used to be a number. The CI tests are cheap; add them before the migration, not after the first incident.
8. Cost
This section prices the measured wall times: TPC-H SF30 on loopback, 720 runs per month, startup excluded, with the rates and assumptions of Section 5.3.
| Platform and engine | Wall time (s) | USD/run | USD/month |
|---|---|---|---|
| VM, DuckDB 2.0.1 | 55.33 | 0.0060 | 4.29 |
| VM, Sail 0.7.3 (reorder) | 71.98 | 0.0078 | 5.59 |
| VM, Comet 1.2.0 | 281.60 | 0.0304 | 21.85 |
| VM, Spark 4.2.0 | 440.09 | 0.0474 | 34.15 |
| Fabric on-demand, Spark 4.2.0 time | 440.09 | 0.1076 | 77.46 |
| Databricks Jobs, Spark 4.2.0 time | 440.09 | 0.1398 | 100.69 |
Same-wall-time cost. This is not a measurement of Databricks Runtime, Photon, the Fabric runtime or Fabric's native engine.
At +10 ms, AAL lowers the Spark 4.2.0 monthly figure from 160.62 to 121.74 USD (Databricks rate) and from 123.56 to 93.64 USD (Fabric rate).
What this means for your platform: the cost ratio is driven by the runtime ratio, not by the price sheet. Even with both prices 50% off in the unfavorable direction, the single-node engine stays several times cheaper for this workload shape. The savings are real only if the correctness and operations items in Sections 6 and 7 are handled.
9. Threats to validity
Every benchmark has limits. These are the ones that could change how you read the numbers above.
Internal.
- Repetitions and correlation. There are two repetitions per cell (Section 4.1). Sessions are correlated within a repetition, so the stratified bootstrap understates uncertainty. The primary interval pools run noise within an engine. It assumes a common log-scale variance across that engine's cells and treats each cell as one degree of freedom.
- Survivorship. The published tables condition on attempts that survived OOMs, stalls and freezes (Section 3.5), and rep 3 was dropped after outcomes that included engine failures. The rep-3 sensitivity analysis does not change any conclusion. Survivorship can still bias the reported times toward favorable runs, most for Spark, which had 12 of the 15 query errors.
- Interference. Box-wide stalls and whole-VM suspensions occurred. The freeze detector reran affected attempts, but its rule changed mid-matrix and it cannot rule out smaller interference.
- Restore and manual run. A box restore from a snapshot happened in the middle of the matrix, and one Spark cell's rep 2 was run by hand three days later.
Construct.
- Session effects. Wall time includes engine-specific session behavior (JIT warmup in Spark despite the SF1 warmup).
- DuckDB semantics. DuckDB ran SQL, not PySpark, and its ETL arithmetic is decimal where PySpark's is double.
-
What "identical" means. Results are identical after normalizing values to two decimals, and the oracle is agreement between engines, not the official TPC-H answer set. The data come from
tpchgen-cli, not the officialdbgen. -
Comet allocator cost. Comet ran with
MALLOC_ARENA_MAX=2. In diagnostic runs (not part of the matrix, each with one box freeze), its per-query times were a median 1.30 times those of a single default-allocator run with the same memory budget (range 0.92 to 1.81;out/comet_mem_summary.json). The Comet ratio in Table 1 may include an allocator cost of that order; I did not isolate it.
External.
- One node. There is no network shuffle, so these results say nothing about the workloads where distributed Spark should win.
- Hardware not exposed. The hypervisor does not expose the CPU model or the storage device.
- Page cache. It was not dropped between runs, so cold and warm reads are not controlled. SF30 fits largely in memory and SF100 does not.
- Not S3. MinIO with a fixed toxiproxy delay is not S3, and no real object store was measured.
- Settings and data. Configurations are defaults, lightly adjusted for the memory cap. TPC-H data is synthetic and uniform.
- Edge-case coverage. The edge cases come from targeted probes, not an exhaustive search.
Conclusion validity.
- The latency break-even is a two-point interpolation.
- The scaling exponents rest on two or three points under non-comparable conditions.
- The cost model multiplies measured times by list prices, prices a larger Databricks node than I measured, and assumes a single-node Fabric session.
10. Conclusion and architect guidance
Answers to the research questions.
- RQ1 (speed). On this node, Sail and DuckDB ran TPC-H about 6 to 8 times faster than Spark 4.2.0, and Comet about 1.6 times faster, with results that agree after two-decimal normalization. The direction holds on every query for Sail and DuckDB in both runs. The size of the effect has interval support under an engine-level noise model; run-level nonparametric certainty needs more repetitions.
- RQ2 (object storage). AAL is a latency fix. On Spark 4.2.0 it was level with classic without added latency and 24% faster at +10 ms, with an interpolated break-even indistinguishable from 0 ms. On Spark 4.1.3 it was 18% slower on loopback, and its break-even, about 2.5 ms, is uncertain enough to include 0.
- RQ3 (correctness). The divergences are explainable. For F1, a binary64 model predicts the affected rows exactly.
- RQ4 (operations and cost). Weigh table-format support and memory behavior at least as heavily as speed when choosing an engine.
Guidance for a customer platform
I work as a data platform architect, so this is how I would turn the results into decisions on a customer platform.
Engine choice by workload.
- DuckDB for single-node batch work you are willing to express in SQL. Check decimal versus double semantics when porting DataFrame code, because "same SQL text" did not mean "same arithmetic" here.
- Sail as a pilot for existing PySpark on internal analytics. Block it for money and civil-time workloads until F1, C1 and C4 are fixed in a release you run. Test the heaviest join under the real memory limit and storage path on every upgrade, since join reorder is the default on Sail main after 0.7.3 (PR #3063, merged 2026-11-19) [20].
- Comet where Spark must stay. Set the allocator from day one and measure its speed cost. Do not expect Delta acceleration from the published 1.2.0 jar.
- Spark stays the choice where the work is truly distributed. This single-node study does not cover that case.
Table formats and upgrades.
- Do not move Iceberg estates to Spark 4.2 until an Iceberg runtime for it is published.
- On real object stores, keep AAL on Spark 4.2. Measure before enabling it on 4.1.3, where it was slower without added latency.
Cost.
- Model cost as runtime times rate plus billed startup, with the formulas of Section 5.3 and your own run counts and startup times. The runtime ratio dominates; the price sheet moves the answer much less.
- Compare per-run managed Spark with an always-on VM using the formula. In this model, with zero billed startup, per-run Databricks Jobs is cheaper than an always-on DuckDB VM below about 67 runs per day, and the always-on VM is cheaper above it. Billed startup lowers that threshold (28.2 runs per day at 600 s).
Governance and a reliable data foundation.
- Put the CI tests of Section 7 in the migration pipeline. Treat them as data contracts: a decimal tie test, a tzdata canary, an exponent-string cast, a permissive-read test and an empty-write schema test.
- Pin everything that changes semantics, not only the engine: the JDK (F1 depends on JDK 19 or later behavior), the embedded tzdata, the Arrow and DataFusion versions, and the table-format runtime.
- Keep money DECIMAL end to end, including literals, and do civil-time conversion at the serving layer from UTC storage.
- Gate releases on result hashes with a documented normalization rule, plus a memory budget test on the heaviest query inside the production cgroup.
- Record every attempt in proofs of concept, including failures, so that survivorship is visible to whoever signs off the migration.
Repetition plan (not run). Run-level nonparametric support for the critical claims needs 3 more repetitions (to ) for 14 cells:
- loopback TPC-H: Spark 4.2.0 classic and AAL, Spark 4.1.3 classic and AAL, Sail reorder, DuckDB, Comet classic;
- proxy0 and proxy10: Spark 4.2.0 classic and AAL;
- local: Spark 4.2.0, Sail no-reorder and DuckDB.
At the minimum exact p is 0.0079, enough for totals and for Holm across 4 queries; Holm across 22 queries would need . The estimated cost:
- Base. From median process times, 4.85 box hours.
- Spark retries. Applying the observed Spark TPC-H retry factor (1.43 attempts per job with a valid run; 40 attempts for 28 jobs in reps 1 and 2) to the Spark cells gives 6.72 hours.
- SF100. Three more SF100 repetitions of DuckDB and Spark add 0.38 hours.
-
Total. About 7.1 box hours (
out/rep_plan.csv,out/rep_plan_summary.json).
The AAL loopback "no effect" claim would need an equivalence design rather than more repetitions of the same test.
11. Engineering tricks and pitfalls from the harness
A benchmark like this one spends more time on the harness than on the engines. These are the problems that actually happened during the runs, in the order I would want to know about them before starting. Each one is recorded in the run log (STATUS.md in the repo), and each fix is in the scripts linked below. None of them changes an engine setting that is timed; they change what is measured around the engines.
11.1 No tc netem: add latency with a TCP proxy
-
Problem. The plan was to add delay to the object store with
tc qdisc ... netem delay 10ms. -
Symptom. The box kernel has no
sch_netemmodule, so the qdisc cannot be created. -
Fix. toxiproxy 2.13.0 in front of MinIO (port 9100 to 9000), with a
latencytoxic set per job and the toxic state stored with every attempt. The proxy at 0 ms is a separate condition, so the proxy's own cost is measured, not assumed. The code is in Section 3.2 above.
11.2 Memory cap without systemd
- Problem. Every engine had to run under the same hard 9 GiB limit with no swap.
-
Symptom.
systemd-run --scope -p MemoryMax=9Gis not available on a box without systemd. -
Fix. Create the cgroup v2 directory directly, write
memory.maxandmemory.swap.max, and have the runner move its own PID intocgroup.procsbefore it starts the engine. The runner also resetsmemory.peakand readsmemory.eventsbefore and after the run, so an OOM kill is detected from the kernel counter, not guessed from an exit code. Snippet in Section 3.2.
11.3 Glob *.parquet, never the directory
-
Problem. At SF100, the first Sail and Comet attempts failed on every query, although all 482 Parquet footers parsed and DuckDB counted 600,037,902
lineitemrows. -
Symptom. Host snapshot sidecars appeared and disappeared next to the data files, named like
lineitem.33.parquet.box-store-snap-<hash>(about 339 MB). Spark listed them as input and failed withFAILED_READ_FILE.FILE_NOT_EXIST; Sail reportedInvalid Parquet file. Corrupt footer. DuckDB was unaffected, because it already globbed*.parquet. -
Fix. Read
f"{path}/*.parquet"in the PySpark job, the same glob DuckDB uses, and time on a copy of the data on a device without snapshots. The failed attempts stay on disk and are listed insuperseded.json.
# scripts/bench2_spark_api.py
spark.read.parquet(f"{path}/*.parquet").createOrReplaceTempView(t)
# scripts/bench2_duckdb.py
con.execute(f"CREATE OR REPLACE VIEW {t} AS SELECT * FROM read_parquet('{path}/*.parquet')")
The general lesson: a directory is not a table. Anything else that lands in it (sidecars, _temporary folders, editor files) becomes input for engines that list the directory.
11.4 Spark keeps shuffle files until a GC runs
- Problem. A full 22-query SF30 session on one Spark driver.
-
Symptom.
r1-loopback-spark413-analyticsfailed Q9 withNo space left on device. Spark'sContextCleanerdeletes a finished query's shuffle files only when the JVM collects the objects that reference them, so 22 queries of shuffle files piled up inspark.local.dir. -
Fix. An untimed GC and a 3 s sleep between queries. After the change,
tmp/sparkdropped back to its baseline after each query; the transient peak was still +16 GB on Q9 and Q18, which is why the disk gate in 11.5 needs 22 GB for Spark and Comet TPC-H.
def untimed_cleanup():
"""Between queries, untimed: trigger a JVM GC so Spark's ContextCleaner removes shuffle files of finished queries
(otherwise SF30 shuffle files pile up in spark.local.dir across 22 queries until the disk fills). No-op for Sail."""
if a.remote: return
try: spark._jvm.System.gc(); time.sleep(3)
except Exception: pass
...
emit(rec); df = None; untimed_cleanup() # after the timed window of each query
11.5 Killed JVMs leak their scratch space: one temp dir per job, and a disk gate
- Problem. An OOM-killed or timed-out JVM never runs its shutdown hooks.
-
Symptom. Two SIGKILLed Comet attempts left
blockmgr-*directories of 5.8 GB and 6.1 GB behind, and the next Spark jobs could not start with enough free disk. -
Fix. Each Spark or Comet job gets its own
spark.local.dirandjava.io.tmpdir, removed by the wrapper whatever the exit code. The orchestrator also skips (without reordering permanently) a job whose disk need is above the free space.
# scripts/run_engine2.sh
JOBTMP=$ROOT/tmp/spark/job-$$-$(date +%s); mkdir -p $JOBTMP
S3A="... --conf spark.local.dir=$JOBTMP --conf spark.driver.extraJavaOptions=-Djava.io.tmpdir=$JOBTMP"
...
[ -n "$JOBTMP" ] && case "$JOBTMP" in $ROOT/tmp/spark/job-*) rm -rf -- "$JOBTMP";; esac # guarded: only ever a job dir
# scripts/orchestrate.py
def need_gb(j):
if j["wl"] == "tpch" and j["cfg"].startswith(("spark", "comet")): return 22
return 10
def runnable(j):
if j["cfg"].startswith("comet") and os.path.exists(f"{ROOT}/COMET_HOLD"): return False
return disk_free_gb() >= need_gb(j)
A related accident: a data copy to a second directory that turned out to be on the same filesystem filled the disk to 90 MB free. Check df on the target, not just the path.
11.6 Comet and glibc arenas: MALLOC_ARENA_MAX=2
- Problem. Comet 1.2.0 runs native code inside the JVM process; the native allocations are outside both the heap and the off-heap pool that Spark accounts for.
- Symptom. With 3g heap plus 4g off-heap, the SF30 run was OOM-killed at Q18 with a tree RSS of 9.59 GB. Shrinking to 2g plus 3g did not help: OOM-killed again at 9.60 GB, and a diagnostic run with GC between queries passed but peaked at 9.55 GB. The process RSS exceeded heap plus off-heap by 3 to 4 GB.
- Fix. Limit glibc to two malloc arenas. Three consecutive SF30 runs under the same cap peaked at 5.4, 5.1 and 5.5 GB. This matches an open upstream issue (apache/datafusion-comet#7108).
comet*) export MALLOC_ARENA_MAX=${COMET_MALLOC_ARENA_MAX:-2} # default glibc arenas OOM at 9 GiB (F2)
If you run any JNI-heavy accelerator under a container limit, measure process RSS, not the JVM's own memory metrics.
11.7 Comma versus colon in extraClassPath
- Problem. For the Delta runs, the table-format jars had to be appended to Comet's jar.
-
Symptom.
comet420-classicDelta attempts 1 and 2 failed Q3, Q12 and Q18 withError loading in-memory sorter check class path. The comma-separated list was valid for--jarsbut not forspark.driver.extraClassPath, which is a JVM classpath, so the Comet jar was invisible to the native shuffle. - Fix.
CJARS=$CJ,$TABLEFMT_JARS
# --jars is comma-separated; extraClassPath is a JVM classpath (colon on Linux).
# A comma here hid the Comet jar from native shuffle (SpillSorter classpath error on Delta Q3/Q12/Q18).
CPATH=$CJ:$(echo "$TABLEFMT_JARS" | tr ',' ':')
A related version trap: there is no iceberg-spark-runtime-4.2 on Maven Central, and the 4.1 runtime fails on Spark 4.2.0 with IncompatibleClassChangeError: Found interface org.apache.spark.sql.connector.catalog.CatalogManager, but class was expected. The Iceberg tables were written with Spark 4.1.3 and read by the engines that could.
11.8 A dead Spark Connect server makes the client retry for minutes
-
Problem. When the cgroup OOM-killed the Sail server (dmesg: process
sail, anon-rss 9.30 GB), the PySpark client did not fail. - Symptom. The client retried the dead server for about 10 minutes per remaining query.
-
Fix. Two layers. The runner watches the server process and stops the client as soon as the server exits (rc 4). The job also exits on the first
UNAVAILABLEorConnection refused. Thensail_resume.pyrecords the in-flight query asSERVER_DIEDand prints the remaining queries, and the wrapper restarts the server for the rest of the session (that is the restart in the RSS figure in Section 5.2).
# scripts/run_one.py
if srv and srv.poll() is not None:
# server process exited under a running client (e.g. OOM-killed): stop the client now instead of letting it retry
server_died = {"server_rc": srv.returncode, "t": time.time()}
for p in psutil.Process(cli.pid).children(recursive=True) + [psutil.Process(cli.pid)]:
try: p.terminate()
except psutil.Error: pass
...
rc = 4; break
# scripts/bench2_spark_api.py
if a.remote and err and ("UNAVAILABLE" in err or "Connection refused" in err or "RETRIES_EXCEEDED" in err):
emit({"event": "server_dead", "q": q}); sys.exit(3)
# scripts/run_engine2.sh: up to 4 more segments after a server death
for SEG in 2 3 4 5; do
REM=$($ROOT/venv-sail/bin/python $ROOT/scripts/sail_resume.py $OUT/queries.jsonl $OUT/summary.jsonl $FULL)
[ -z "$REM" ] && break
sleep 5
$ROOT/venv-sail/bin/python $ROOT/scripts/run_one.py ... --server "$ROOT/venv-sail/bin/sail spark server --port 50051" --server-wait-port 50051 -- \
$ROOT/venv-sail/bin/python $ROOT/scripts/bench2_spark_api.py --remote sc://127.0.0.1:50051 $COMMON --queries $REM
done
11.9 A stale server on the port invalidates a whole repetition
- Problem. A smoke-test Sail server (no join reorder, 3 GB RSS) was still listening on port 50051 when the pilot started.
- Symptom. Both Sail configurations of pilot rep 1 connected to it, so the reorder setting had no effect, and its memory sat on the box during the Spark runs of the same rep. Rep 1 of the pilot was invalid.
-
Fix. Refuse to start if the port is already taken, start the server with
execin its own session, and kill the whole process group afterwards.
if a.server:
try:
socket.create_connection(("127.0.0.1", a.server_wait_port), 0.5).close()
sys.exit(f"port {a.server_wait_port} already in use before server start; refusing to run")
except OSError: pass
srv = subprocess.Popen("exec " + a.server, shell=True, stdout=open(f"{a.rss_out}.server.log","w"), stderr=subprocess.STDOUT, start_new_session=True)
...
if srv:
try: os.killpg(srv.pid, signal.SIGTERM)
except ProcessLookupError: pass
11.10 Stalls: a no-progress watchdog instead of a long timeout
- Problem. Some Spark attempts stopped making progress without failing (finding F4).
-
Symptom. With the original 90-minute job timeout, three attempts still lasted 83,514 s, 102,435 s and 25,273 s (hung on Q1 or on the start of Q3), while
cpu_userwas only a few minutes. These records stay in the data as F4 stall evidence. -
Fix. The job timeout went from 5400 s to 1800 s, and the runner kills the tree after 1200 s with no new line in
queries.jsonl. It appends aSTALLED_NO_PROGRESSquery record and exits 0, so the orchestrator records a query error and retries.
STALL_PROGRESS_S = 1200 # 20 min with no queries.jsonl progress: treat as stall (F4 evidence), do not wait for the job timeout
...
while True:
rc = cli.poll()
if rc is not None: break
if time.time() - last_progress(tstart) > STALL_PROGRESS_S:
stalled = True
try: mark_stalled(tstart) # appends {"event": "query", "error": "STALLED_NO_PROGRESS", ...}
except Exception: pass
# rc=0 + query error => orchestrator records qerror and retries (like a freeze)
kill_tree()
rc = 0
break
if a.timeout and time.time() - tstart > a.timeout:
timed_out = True; rc = kill_tree(-9); ...
time.sleep(0.5)
11.11 The whole VM can pause: detect freezes from your own sampler
- Problem. The benchmark box is a VM that can be paused by its host.
-
Symptom. In the pilot, box-wide stalls of 446 s, 295 s and 31 s, during which the RSS sampler froze too. On one evening, every sampler gap over 30 s matched
systemdwatchdog timeouts indmesg. With the first, strict freeze rule, 2 to 6 s blips forced full 8 to 13 minute reruns (6 of about 50 attempts). -
Fix. The 0.2 s RSS sampler doubles as a clock. A gap in its timestamps that overlaps a query and is longer than 2 s and longer than 10 s or 5% of that query's time marks the attempt as frozen and reruns it (
freeze_checkin Section 3.5). The rule was refined once during the matrix, at 04:35 TR, and Section 9 lists that change as a threat to validity.
11.12 After a VM restore, the memory balloon holds your RAM
-
Problem. After a box restore, the
virtio_balloondriver kept about 10 GB. -
Symptom.
MemAvailablewas 3.4 GB of 16 GB, which would have turned a 9 GiB cap into a much smaller effective limit. -
Fix. Touch memory in 1 GiB steps between jobs (untimed) until the balloon deflates, then release it. After pumping,
MemAvailablewas 11.9 GB. The orchestrator runs the pump wheneverMemAvailableis below 10.5 GB and waits while it is below 9.5 GB.
# scripts/mem_pump.py
target_kb = float(sys.argv[1] if len(sys.argv) > 1 else 11.0) * 1024**2
def avail(): return int(open('/proc/meminfo').read().split('MemAvailable:')[1].split()[0])
b = []
for i in range(14):
if avail() >= target_kb and not b: break
if avail() < 600 * 1024: break # never push the box into OOM
b.append(bytearray(1024**3)); time.sleep(1.0)
del b; time.sleep(2)
11.13 Small things that would have broken the comparison
-
DuckDB's file cache. In the pilot, DuckDB's Q6 issued 0 GETs because a previous query had cached the data. Fix:
SET enable_external_file_cache=falseand a fresh process per run. -
One SQL text for every engine. Q15 uses a view; Spark rejects a permanent view over temp views, so
create viewbecamecreate temp view, for all engines. -
Seeded order is not executed order. The job order was shuffled with
random.Random(1000 + r).shuffle(jobs)per repetition, and the 125 first starts kept that order (0 inversions). Retries did not: 23 ran immediately after the failed attempt and 9 later, and the disk gate and the Comet hold paused the queue, which changed the box state between jobs. This is why Section 3.5 treats randomization as partly lost.
12. Reproducibility
Everything is in the public repository: github.com/firfircelik/pyspark-engine-swap-bench. The paper PDF is at paper/paper.pdf.
firfircelik
/
pyspark-engine-swap-bench
Keep your PySpark code, swap the engine: Spark 4.1/4.2, Comet, Sail and DuckDB on speed, correctness, S3 latency (AAL), Iceberg/Delta and cost. Harness, raw results, paper.
Keep your PySpark code, swap the engine
A controlled single-node study of Apache Spark 4.1.3 / 4.2.0, Apache DataFusion Comet 1.2.0, Sail 0.7.3 and DuckDB 2.0.1 on speed, correctness, object-store latency (S3A classic stream vs the Analytics Accelerator Library), table formats (Iceberg, Delta) and cost.
- Paper (20 pages, all tables, models, proofs and source locations):
paper/paper.pdf(source:paper/paper.md) - Author: Firat Celik, Senior Data Platform Architect
Research questions
- RQ1 (speed). With identical job code (Comet, Sail) or identical SQL (DuckDB), how does wall time compare to Spark on the same node, memory cap and data, and how certain are we given the number of repetitions?
- RQ2 (object storage). How does the S3A input stream (classic vs AAL) interact with request latency, and at what latency does AAL start to pay off?
- RQ3 (correctness). Where do results diverge from Spark, why, and can the divergence be predicted from first principles?
- RQ4…
-
scripts/:-
run_one.py: cgroup placement, RSS sampler and freeze detection. -
orchestrate.py: seeded shuffled matrix, resumable. -
bench2_spark_api.py: one PySpark job file for Spark, Comet and Sail. -
run_extra_r2_a4.py: the manual fourth attempt. - Also
run_engine2.sh,bench2_duckdb.py,verify_etl.py,aggregate2.py,aggregate_sf100.pyandcheck_stream.py.
-
-
queries/: the 22 TPC-H queries as run (Q15 usescreate temp view). -
repro/minimal/: the C1, C4, C5, C7, C8 and Comet time zone scripts,run_all.shand outputs. -
results/: published CSVs and per-run JSON logs, includingstate.jsonlwith every attempt, for Phase 2, AAL isolation, table formats and SF100. Per-row query outputs and Parquet data are not included; result hashes are in the per-run logs. The F1 mismatch keys are inarticle/academic/out/f1_mismatch_orderkeys.csv. -
article/academic/analysis/:stats.py,models.py,ieee.py,f1_rows.py,f1_drift.py,deviations.py,tz.py,comet_mem.py,figs.py(paper figures) andfigs_devto.py(the extra figures in this article), with outputs inout/. The random seed is 20261126. The root directory is taken fromENGINE_SWAP_ROOT(default: the checkout). -
VERSIONS.md: every version in Section 3.1, with jar checksums, the MinIO tag, cgroup and engine settings.
Data is regenerated with tpchgen-cli 4.0.0:
cargo install tpchgen-cli --version 4.0.0
tpchgen-cli -s 30 --format=parquet --parts=24 --compression=SNAPPY --output-dir=$ROOT/data/tpch-sf30
tpchgen-cli -s 100 --format=parquet --parts=80 --compression=SNAPPY --output-dir=$ROOT/data/tpch-sf100
To rerun the analysis from the published results:
cd article/academic/analysis
export ENGINE_SWAP_ROOT=$(git rev-parse --show-toplevel)
python3 stats.py && python3 deviations.py && python3 models.py
python3 ieee.py && python3 tz.py && python3 comet_mem.py && python3 figs.py
python3 figs_devto.py # reads out/f1_drift_hist.csv, written by f1_drift.py (needs duckdb and the SF30 data)
# f1_rows.py needs MinIO with the E6 ETL outputs and BENCH_S3_KEY / BENCH_S3_SECRET;
# ieee.py and f1_rows.py need the duckdb Python package
References
[1] Transaction Processing Performance Council. TPC Benchmark H Standard Specification, Revision 3.0.1. https://www.tpc.org/tpch/
[2] P. Boncz, T. Neumann, O. Erling. TPC-H Analyzed: Hidden Messages and Lessons Learned from an Influential Benchmark. TPCTC 2013, LNCS 8391, 2014. doi:10.1007/978-3-319-04936-6_5
[3] M. Armbrust et al. Spark SQL: Relational Data Processing in Spark. SIGMOD 2015. doi:10.1145/2723372.2742797
[4] M. Zaharia et al. Apache Spark: A Unified Engine for Big Data Processing. Communications of the ACM 59(11), 2016. doi:10.1145/2934664
[5] M. Raasveldt, H. Mühleisen. DuckDB: an Embeddable Analytical Database. SIGMOD 2019 (demo). doi:10.1145/3299869.3320212
[6] M. Raasveldt, H. Mühleisen. Data Management for Data Science: Towards Embedded Analytics. CIDR 2020. https://www.cidrdb.org/cidr2020/papers/p23-raasveldt-cidr20.pdf
[7] A. Lamb et al. Apache Arrow DataFusion: A Fast, Embeddable, Modular Analytic Query Engine. SIGMOD Companion 2024. doi:10.1145/3626246.3653368
[8] M. Armbrust et al. Delta Lake: High-Performance ACID Table Storage over Cloud Object Stores. PVLDB 13(12), 2020. doi:10.14778/3415478.3415560
[9] D. Durner, V. Leis, T. Neumann. Exploiting Cloud Object Storage for High-Performance Analytics. PVLDB 16(11), 2023. doi:10.14778/3611479.3611486
[10] IEEE Standard for Floating-Point Arithmetic, IEEE Std 754-2019. doi:10.1109/IEEESTD.2019.8766229
[11] D. Goldberg. What Every Computer Scientist Should Know About Floating-Point Arithmetic. ACM Computing Surveys 23(1), 1991. doi:10.1145/103162.103163
[12] T. Hoefler, R. Belli. Scientific Benchmarking of Parallel Computing Systems. SC15. doi:10.1145/2807591.2807644
[13] T. Kalibera, R. Jones. Rigorous Benchmarking in Reasonable Time. ISMM 2013. doi:10.1145/2464157.2464160
[14] N. Cliff. Dominance Statistics: Ordinal Analyses to Answer Ordinal Questions. Psychological Bulletin 114(3), 1993. doi:10.1037/0033-2909.114.3.494
[15] S. Holm. A Simple Sequentially Rejective Multiple Test Procedure. Scandinavian Journal of Statistics 6(2), 65-70, 1979. https://www.jstor.org/stable/4615733
[16] Apache Iceberg. Iceberg Spark 4.2 feature tracking, issue #17959. https://github.com/apache/iceberg/issues/17959
[17] Apache DataFusion Comet. Draft PR #4669 "feat: support native Comet scan of plain Delta Lake tables" and the contrib Delta scan PRs #4700, #4952, #5365 (merged 2026-07-10, 2026-08-19, 2026-10-13). https://github.com/apache/datafusion-comet/pull/4669 (accessed 2026-11-26)
[18] Amazon Web Services. Performance design patterns for Amazon S3. Amazon S3 User Guide. https://docs.aws.amazon.com/AmazonS3/latest/userguide/optimizing-performance-design-patterns.html (accessed 2026-11-26)
[19] Microsoft. Apache Spark billing and utilization in Microsoft Fabric. Microsoft Learn. https://learn.microsoft.com/en-us/fabric/data-engineering/billing-capacity-management-for-spark (accessed 2026-11-26)
[20] Upstream issues and pull requests referenced in Sections 7 and 10 (all accessed 2026-11-26): lakehq/sail #3024, #3063, #3107; apache/datafusion-comet #6331, #6353, #7108, #7344. https://github.com/lakehq/sail, https://github.com/apache/datafusion-comet
[21] LakeSail. Sail: a Spark-compatible compute engine (Spark Connect server in Rust). https://github.com/lakehq/sail
[22] Apache DataFusion Comet documentation, including the benchmarking guide. https://datafusion.apache.org/comet/
[23] Apache Hadoop. Hadoop-AWS module: Integration with Amazon Web Services (S3A), and "Reading data from S3". https://hadoop.apache.org/docs/current/hadoop-aws/tools/hadoop-aws/reading.html
[24] Amazon Web Services Labs. Analytics Accelerator Library for Amazon S3. https://github.com/awslabs/analytics-accelerator-s3
[25] MinIO. High-performance S3-compatible object storage. https://github.com/minio/minio
[26] tpchgen-rs / tpchgen-cli: TPC-H data generator in Rust. https://github.com/clflushopt/tpchgen-rs
[27] chrono-tz: time zone database for the chrono crate. https://github.com/chronotope/chrono-tz
[28] OpenJDK. JDK-4511638: Double.toString(double) sometimes produces incorrect results (fixed in JDK 19). https://bugs.openjdk.org/browse/JDK-4511638; JDK 19 release notes, https://www.oracle.com/java/technologies/javase/19-relnote-issues.html
[29] ClickHouse. ClickBench: a benchmark for analytical databases. https://github.com/ClickHouse/ClickBench
[30] DuckDB Labs. Database-like ops benchmark. https://duckdblabs.github.io/db-benchmark/
[31] IANA. Time Zone Database. https://www.iana.org/time-zones
[32] Shopify. Toxiproxy: a TCP proxy to simulate network and system conditions. https://github.com/Shopify/toxiproxy
[33] Microsoft. Azure Retail Prices REST API. https://prices.azure.com/api/retail/prices (read 2026-11-26)
[34] Microsoft. Azure Databricks pricing. https://azure.microsoft.com/en-us/pricing/details/databricks/ (read 2026-11-26)
[35] A. Mozzillo, L. Zecchini, L. Gagliardelli, A. Aslam, S. Bergamaschi, G. Simonini. Evaluation of Dataframe Libraries for Data Preparation on a Single Machine. EDBT 2025, pp. 337-349. arXiv:2312.11122
[36] M.-A. Szőke. Modern alternatives to Hive: A systematic review and single-node benchmark of SQL-on-Hadoop and lakehouse engines. Information Systems 136, 102635, 2026 (online 2025). doi:10.1016/j.is.2025.102635
















Top comments (0)