<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spill_(memory)</id>
	<title>Spill (memory) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spill_(memory)"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spill_(memory)&amp;action=history"/>
	<updated>2026-12-06T00:13:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Spill_(memory)&amp;diff=204&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@7c9abaa</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spill_(memory)&amp;diff=204&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:59Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@7c9abaa&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Spill&lt;br /&gt;
| also_known_as   = Spill to disk, memory spill&lt;br /&gt;
| field           = Distributed data processing&lt;br /&gt;
| key_parts       = Execution memory, spill files on local disk, spill metrics&lt;br /&gt;
| implementations = [[Apache Spark]], [[Trino]], [[Apache Flink]]&lt;br /&gt;
| related         = [[Spark memory management]], [[Shuffle]], [[Data skew]], [[Executor]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (docs/web-ui.md, docs/monitoring.md, docs/tuning.md, docs/configuration.md, docs/rdd-programming-guide.md), the Trino 484 docs (Spill to disk, Spilling properties) and the Apache Flink 2.3 docs (TaskManager memory, memory tuning, configuration)}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Spill&amp;#039;&amp;#039;&amp;#039; is the act of a query engine writing intermediate data from memory to local disk while an operation runs, because the data for a sort, aggregation, join or shuffle does not fit in the memory the operation is allowed to use. In [[Apache Spark]], a task spills when its share of execution memory is full; the task keeps running, reads the spilled data back later, and finishes slower instead of failing.&amp;lt;ref name=&amp;quot;rddguide&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/rdd-programming-guide.html#shuffle-operations |title=RDD Programming Guide: Shuffle operations (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;tuning&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/tuning.html |title=Tuning Spark (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; [[Trino]] and [[Apache Flink]] spill too, under different rules.&lt;br /&gt;
&lt;br /&gt;
== What is spill in Apache Spark? ==&lt;br /&gt;
Spark divides each executor&amp;#039;s unified memory region into execution memory, used for shuffles, joins, sorts and aggregations, and storage memory, used for cached data.&amp;lt;ref name=&amp;quot;tuning&amp;quot; /&amp;gt; Shuffle operations build in-memory structures to organize records; when these do not fit, Spark spills them to disk, which adds disk I/O and garbage collection.&amp;lt;ref name=&amp;quot;rddguide&amp;quot; /&amp;gt; Spill files go to the scratch directories in &amp;lt;code&amp;gt;spark.local.dir&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;/tmp&amp;lt;/code&amp;gt;), and data spilled during shuffles is compressed by default (&amp;lt;code&amp;gt;spark.shuffle.spill.compress&amp;lt;/code&amp;gt;).&amp;lt;ref name=&amp;quot;config&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/configuration.html |title=Spark Configuration (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Spill is not the same as shuffle files. Shuffle files are the normal output of the map side of a [[shuffle]], written by every shuffle; spill files are temporary overflow inside one task. A shuffle with no spill still writes shuffle files.&amp;lt;ref name=&amp;quot;rddguide&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spill metrics in the Spark UI ==&lt;br /&gt;
The Spark UI reports spill in two places.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Stage page.&amp;#039;&amp;#039;&amp;#039; The task summary and the per-executor table show &amp;#039;&amp;#039;&amp;#039;Shuffle spill (memory)&amp;#039;&amp;#039;&amp;#039;, the size of the spilled data in its deserialized form in memory, and &amp;#039;&amp;#039;&amp;#039;Shuffle spill (disk)&amp;#039;&amp;#039;&amp;#039;, the size of its serialized form on disk.&amp;lt;ref name=&amp;quot;webui&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/web-ui.html |title=Web UI (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The memory figure is usually the larger of the two, because the serialized and compressed form on disk is smaller.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;SQL tab.&amp;#039;&amp;#039;&amp;#039; Operators such as &amp;lt;code&amp;gt;Sort&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;HashAggregate&amp;lt;/code&amp;gt; show a &amp;lt;code&amp;gt;spill size&amp;lt;/code&amp;gt; metric (bytes spilled to disk by that operator) next to &amp;lt;code&amp;gt;peak memory&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;webui&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The same numbers are in the task metrics of the REST API and event log as &amp;lt;code&amp;gt;memoryBytesSpilled&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;diskBytesSpilled&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;monitoring&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/monitoring.html |title=Monitoring and Instrumentation (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What causes spill? ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Too few shuffle partitions.&amp;#039;&amp;#039;&amp;#039; Each task gets a larger slice of data. &amp;lt;code&amp;gt;spark.sql.shuffle.partitions&amp;lt;/code&amp;gt; defaults to 200; with [[Adaptive Query Execution]] on, Spark starts from that number and coalesces small partitions.&amp;lt;ref name=&amp;quot;perf&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/sql-performance-tuning.html |title=Performance Tuning (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;[[Data skew]].&amp;#039;&amp;#039;&amp;#039; One task gets most of the data, so only that task spills.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Little execution memory per task.&amp;#039;&amp;#039;&amp;#039; All running tasks on an executor share its execution memory, so more cores per executor means less memory per task. The region size is set by &amp;lt;code&amp;gt;spark.executor.memory&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.memory.fraction&amp;lt;/code&amp;gt; (default 0.6).&amp;lt;ref name=&amp;quot;tuning&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Large cached datasets.&amp;#039;&amp;#039;&amp;#039; Cached blocks occupy storage memory. Execution can evict them, but only down to &amp;lt;code&amp;gt;spark.memory.storageFraction&amp;lt;/code&amp;gt; (default 0.5) of the region.&amp;lt;ref name=&amp;quot;tuning&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Common fixes follow from the causes: more shuffle partitions, fixing skew, more memory per executor or fewer cores per executor, and caching less. A small amount of spill is normal; it matters when spill dominates a stage&amp;#039;s run time.&lt;br /&gt;
&lt;br /&gt;
== Spill compared across engines ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Apache Spark !! Trino !! Apache Flink&lt;br /&gt;
|-&lt;br /&gt;
! Default behaviour&lt;br /&gt;
| Always on; tasks spill execution data when memory runs out&amp;lt;ref name=&amp;quot;rddguide&amp;quot; /&amp;gt;&lt;br /&gt;
| Off (&amp;lt;code&amp;gt;spill-enabled&amp;lt;/code&amp;gt; defaults to false); without it, queries over the memory limits are killed&amp;lt;ref name=&amp;quot;trinospillprops&amp;quot;&amp;gt;{{Cite web |url=https://trino.io/docs/current/admin/properties-spilling.html |title=Spilling properties (Trino 484) |publisher=Trino Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;trinospill&amp;quot;&amp;gt;{{Cite web |url=https://trino.io/docs/current/admin/spill.html |title=Spill to disk (Trino 484) |publisher=Trino Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
| For batch jobs, Flink spills to disk when managed memory is not enough&amp;lt;ref name=&amp;quot;flinktuning&amp;quot;&amp;gt;{{Cite web |url=https://nightlies.apache.org/flink/flink-docs-stable/docs/deployment/memory/mem_tuning/ |title=Memory tuning guide (Apache Flink 2.3) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Memory that spills&lt;br /&gt;
| Execution memory in the executor&amp;#039;s unified region (heap, or off-heap if enabled)&amp;lt;ref name=&amp;quot;tuning&amp;quot; /&amp;gt;&lt;br /&gt;
| Revocable memory, which does not count toward query limits and which the memory manager can take back&amp;lt;ref name=&amp;quot;trinospill&amp;quot; /&amp;gt;&lt;br /&gt;
| Managed memory, native (off-heap) memory used for sorting, hash tables and cached intermediate results; by default 0.4 of total Flink memory (&amp;lt;code&amp;gt;taskmanager.memory.managed.fraction&amp;lt;/code&amp;gt;)&amp;lt;ref name=&amp;quot;flinkmem&amp;quot;&amp;gt;{{Cite web |url=https://nightlies.apache.org/flink/flink-docs-stable/docs/deployment/memory/mem_setup_tm/ |title=Set up TaskManager Memory (Apache Flink 2.3) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;flinkconfig&amp;quot;&amp;gt;{{Cite web |url=https://nightlies.apache.org/flink/flink-docs-stable/docs/deployment/config/ |title=Configuration (Apache Flink 2.3) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Where spill goes&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.local.dir&amp;lt;/code&amp;gt;&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;spiller-spill-path&amp;lt;/code&amp;gt;, which must be set when spilling is on; a comma-separated list spreads spill over several disks&amp;lt;ref name=&amp;quot;trinospillprops&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;io.tmp.dirs&amp;lt;/code&amp;gt; (default: the JVM temporary directory), which also holds RocksDB files and cached jars&amp;lt;ref name=&amp;quot;flinkconfig&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Operations that spill&lt;br /&gt;
| Shuffle, sort, aggregation and join structures&amp;lt;ref name=&amp;quot;rddguide&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;webui&amp;quot; /&amp;gt;&lt;br /&gt;
| Joins, aggregations, &amp;lt;code&amp;gt;ORDER BY&amp;lt;/code&amp;gt; and window functions&amp;lt;ref name=&amp;quot;trinospill&amp;quot; /&amp;gt;&lt;br /&gt;
| Batch algorithms such as external sorts and hash joins&amp;lt;ref name=&amp;quot;flinkconfig&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Status&lt;br /&gt;
| Core part of execution&lt;br /&gt;
| The Trino docs call spill to disk legacy functionality and point to fault-tolerant execution with the task retry policy instead&amp;lt;ref name=&amp;quot;trinospill&amp;quot; /&amp;gt;&lt;br /&gt;
| Core part of batch execution&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In Trino, spill is enabled per cluster and is limited by &amp;lt;code&amp;gt;max-spill-per-node&amp;lt;/code&amp;gt; (all queries on a node) and &amp;lt;code&amp;gt;query-max-spill-per-node&amp;lt;/code&amp;gt; (one query on a node), both 100GB by default.&amp;lt;ref name=&amp;quot;trinospillprops&amp;quot; /&amp;gt; The Trino docs warn that a query forced to spill may run orders of magnitude longer than one that runs in memory, and that spill does not guarantee that every memory-intensive query will succeed.&amp;lt;ref name=&amp;quot;trinospill&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Spark memory management]]&lt;br /&gt;
* [[Shuffle]]&lt;br /&gt;
* [[Data skew]]&lt;br /&gt;
* [[Executor]]&lt;br /&gt;
* [[Garbage collection in Spark]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>