My pyspark code has the following statement:
where df is a long, skinny (450M rows, 10 columns) dataframe. So this creates one large window for the whole dataframe to sort over.
In spark 2.1 this works without problem, in spark 2.2 this fails either with out of memory exception or too many open files exception, depending on memory settings (which is what I tried first to fix this).
Monitoring the blockmgr, I see that spark 2.1 creates 152 files, spark 2.2 creates >110,000 files.
In the log I see the following messages (110,000 of these):
So I started hunting for clues in UnsafeExternalSorter, without luck. What I had missed was this one message:
Which allowed me to track down the issue.
By changing the configuration to include:
I got it to work again and with the same performance as spark 2.1.
I have workflows where I use windowing functions that do not fail, but took a performance hit due to the excessive spilling when using the default of 4096.
I think to make it easier to track down these issues this config variable should be included in the configuration documentation.
Maybe 4096 is too small of a default value?