This is an automated email from the ASF dual-hosted git repository.

dongjoon-hyun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new c094224fb6c8 [SPARK-61620][SQL][TEST] Add a shuffled-query case to 
`ArrowCacheBenchmark`
c094224fb6c8 is described below

commit c094224fb6c82f96831b4259ce575c2d677d068a
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Fri Nov 13 02:04:50 2026 -0800

    [SPARK-61620][SQL][TEST] Add a shuffled-query case to `ArrowCacheBenchmark`
    
    ### What changes were proposed in this pull request?
    
    This PR adds a new section, `Cache a shuffled query`, to 
`ArrowCacheBenchmark`, right after `Cache columnar input (Parquet)`. It caches 
5M rows of `int`, `long` and `double` columns after `repartition(1)`, once with 
`DefaultCachedBatchSerializer` and once with `ArrowCachedBatchSerializer`, and 
times the cache build, including the shuffle.
    
    ```scala
    val df = spark.range(numRows).repartition(1).selectExpr(
      "id as int_col",
      "id * 2L as long_col",
      "cast(id as double) as double_col"
    )
    timer.startTiming()
    df.cache()
    df.count() // Materialize cache
    timer.stopTiming()
    ```
    
    ### Why are the changes needed?
    
    No existing `ArrowCacheBenchmark` case caches data through 
`RowToColumnarExec`.
    - The `spark.range(...).selectExpr(...)` queries have no exchange, so AQE 
does not apply to the cached plan, and the serializer receives rows 
(`convertInternalRowToCachedBatch`).
    - The Parquet section produces columnar batches from the start.
    
    When the cached query has an exchange, AQE plans it. For a serializer that 
takes columnar input, like `ArrowCachedBatchSerializer`, 
`CachedBatchSerializer.convertToColumnarPlanIfPossible` turns the plan into 
`AdaptiveSparkPlanExec(supportsColumnar = true)`, and AQE adds `RowToColumnar` 
at the end of the final stage. The final plan of the new Arrow case is:
    
    ```
    ResultQueryStage
    +- RowToColumnar
       +- Project
          +- ShuffleQueryStage
    ```
    
    So this is the path that a cached query with an exchange, such as an 
aggregation or a join, takes with the Arrow cache, and the new section makes 
the cost of `RowToColumnarExec` on that path measurable. 
`DefaultCachedBatchSerializer` takes rows, so its case runs the same query 
without `RowToColumnarExec`.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. This is a test-only change to a benchmark class.
    
    ### How was this patch tested?
    
    Benchmark-only change. The results files, `ArrowCacheBenchmark-results.txt` 
(JDK 21) and `ArrowCacheBenchmark-jdk25-results.txt` (JDK 25), are regenerated 
with the GitHub Actions `benchmark.yml` workflow on `AMD EPYC 7763` for both 
JDKs. The JDK 25 file was previously generated on `Intel(R) Xeon(R) 6973P-C`. 
The regenerated files also include the existing `Cache with column pruning (sum 
1 of 50 columns)` section, which SPARK-58918 added without regenerating the 
results files.
    
    The new section on JDK 21:
    
    ```
    OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1019-azure
    AMD EPYC 7763 64-Core Processor
    Cache 5M rows after a shuffle:            Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
    
------------------------------------------------------------------------------------------------------------------------
    Default cache - shuffled input                     2145           2176      
    43          2.3         429.0       1.0X
    Arrow cache - shuffled input                       2048           2051      
     4          2.4         409.6       1.0X
    ```
    
    The new section on JDK 25:
    
    ```
    OpenJDK 64-Bit Server VM 25.0.5.0.3+1-LTS on Linux 7.0.0-1019-azure
    AMD EPYC 7763 64-Core Processor
    Cache 5M rows after a shuffle:            Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
    
------------------------------------------------------------------------------------------------------------------------
    Default cache - shuffled input                     2137           2178      
    58          2.3         427.3       1.0X
    Arrow cache - shuffled input                       1894           1904      
    13          2.6         378.9       1.1X
    ```
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Opus 5.5
    
    Closes #60438 from dongjoon-hyun/SPARK-61620.
    
    Authored-by: Dongjoon Hyun <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
    
    
    skip-checks: true
---
 .../ArrowCacheBenchmark-jdk25-results.txt          | 109 +++++++++++++--------
 .../benchmarks/ArrowCacheBenchmark-results.txt     |  99 ++++++++++++-------
 .../execution/benchmark/ArrowCacheBenchmark.scala  |  45 +++++++++
 3 files changed, 178 insertions(+), 75 deletions(-)

diff --git a/sql/core/benchmarks/ArrowCacheBenchmark-jdk25-results.txt 
b/sql/core/benchmarks/ArrowCacheBenchmark-jdk25-results.txt
index 96df592625ca..5157e44c7092 100644
--- a/sql/core/benchmarks/ArrowCacheBenchmark-jdk25-results.txt
+++ b/sql/core/benchmarks/ArrowCacheBenchmark-jdk25-results.txt
@@ -6,80 +6,109 @@ Arrow Cache vs Default Cache
 Cache primitive types
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 25.0.4+7-LTS on Linux 6.17.0-1020-azure
-Intel(R) Xeon(R) 6973P-C
+OpenJDK 64-Bit Server VM 25.0.5.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
 Cache 5M rows with primitives:               Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
---------------------------------------------------------------------------------------------------------------------------
-Default cache - write + read                          1521           1694      
   245          3.3         304.1       1.0X
-Default cache - write + read (uncompressed)           1012           1088      
   107          4.9         202.4       1.5X
-Arrow cache - write + read                            1185           1189      
     6          4.2         236.9       1.3X
-Arrow cache - write + read (zstd level -1)            1519           1537      
    24          3.3         303.9       1.0X
-Arrow cache - write + read (zstd level 1)             1390           1417      
    39          3.6         277.9       1.1X
-Arrow cache - write + read (zstd level 3)             1403           1413      
    15          3.6         280.6       1.1X
+Default cache - write + read                          1923           2048      
   177          2.6         384.6       1.0X
+Default cache - write + read (uncompressed)           1404           1444      
    56          3.6         280.9       1.4X
+Arrow cache - write + read                            1625           1641      
    23          3.1         325.0       1.2X
+Arrow cache - write + read (zstd level -1)            2213           2225      
    18          2.3         442.6       0.9X
+Arrow cache - write + read (zstd level 1)             2239           2245      
     7          2.2         447.9       0.9X
+Arrow cache - write + read (zstd level 3)             2297           2321      
    34          2.2         459.4       0.8X
 
 
 
================================================================================================
 Cache then filter
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 25.0.4+7-LTS on Linux 6.17.0-1020-azure
-Intel(R) Xeon(R) 6973P-C
+OpenJDK 64-Bit Server VM 25.0.5.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
 Cache 5M rows, then filter:               Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
------------------------------------------------------------------------------------------------------------------------
-Default cache - filter                             1280           1296         
 22          3.9         256.0       1.0X
-Default cache - filter (uncompressed)              1017           1078         
 86          4.9         203.4       1.3X
-Arrow cache - filter                               1178           1259         
114          4.2         235.5       1.1X
-Arrow cache - filter (zstd level -1)               1324           1343         
 26          3.8         264.9       1.0X
-Arrow cache - filter (zstd level 1)                1345           1372         
 38          3.7         269.0       1.0X
-Arrow cache - filter (zstd level 3)                1408           1413         
  7          3.6         281.6       0.9X
+Default cache - filter                             1972           1980         
 11          2.5         394.5       1.0X
+Default cache - filter (uncompressed)              1834           1864         
 43          2.7         366.7       1.1X
+Arrow cache - filter                               1912           1953         
 58          2.6         382.4       1.0X
+Arrow cache - filter (zstd level -1)               2262           2299         
 52          2.2         452.4       0.9X
+Arrow cache - filter (zstd level 1)                2366           2380         
 20          2.1         473.3       0.8X
+Arrow cache - filter (zstd level 3)                2449           2464         
 21          2.0         489.7       0.8X
 
 
 
================================================================================================
 Cache columnar input (Parquet)
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 25.0.4+7-LTS on Linux 6.17.0-1020-azure
-Intel(R) Xeon(R) 6973P-C
+OpenJDK 64-Bit Server VM 25.0.5.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
 Cache 2M rows from Parquet:                    Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
-----------------------------------------------------------------------------------------------------------------------------
-Default cache - columnar input                          1182           1183    
       1          1.7         591.2       1.0X
-Default cache - columnar input (uncompressed)           1151           1185    
      49          1.7         575.3       1.0X
-Arrow cache - columnar input                            1060           1065    
       6          1.9         530.0       1.1X
-Arrow cache - columnar input (zstd level -1)            1187           1191    
       5          1.7         593.6       1.0X
-Arrow cache - columnar input (zstd level 1)             1198           1217    
      27          1.7         599.0       1.0X
-Arrow cache - columnar input (zstd level 3)             1243           1259    
      22          1.6         621.5       1.0X
+Default cache - columnar input                          2236           2279    
      60          0.9        1117.9       1.0X
+Default cache - columnar input (uncompressed)           1987           1996    
      13          1.0         993.4       1.1X
+Arrow cache - columnar input                            1954           2001    
      67          1.0         977.2       1.1X
+Arrow cache - columnar input (zstd level -1)            2348           2368    
      28          0.9        1174.1       1.0X
+Arrow cache - columnar input (zstd level 1)             2381           2384    
       4          0.8        1190.4       0.9X
+Arrow cache - columnar input (zstd level 3)             2403           2427    
      34          0.8        1201.4       0.9X
+
+
+================================================================================================
+Cache a shuffled query
+================================================================================================
+
+OpenJDK 64-Bit Server VM 25.0.5.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
+Cache 5M rows after a shuffle:            Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
+------------------------------------------------------------------------------------------------------------------------
+Default cache - shuffled input                     2123           2195         
101          2.4         424.7       1.0X
+Arrow cache - shuffled input                       1980           1985         
  8          2.5         396.0       1.1X
+Arrow cache - shuffled input (AQE off)             1583           1603         
 29          3.2         316.5       1.3X
 
 
 
================================================================================================
 Re-cache Arrow cached data (zero-copy test)
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 25.0.4+7-LTS on Linux 6.17.0-1020-azure
-Intel(R) Xeon(R) 6973P-C
+OpenJDK 64-Bit Server VM 25.0.5.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
 Re-cache 2M rows (zero-copy):                     Best Time(ms)   Avg Time(ms) 
  Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
--------------------------------------------------------------------------------------------------------------------------------
-Default cache - cache a cached DF                           282            308 
         29          7.1         141.1       1.0X
-Default cache - cache a cached DF (uncompressed)            128            138 
         11         15.7          63.8       2.2X
-Arrow cache - cache a cached DF (zero-copy)                 101            115 
         13         19.8          50.5       2.8X
-Arrow cache - cache a cached DF (zstd level -1)             219            226 
         17          9.1         109.3       1.3X
-Arrow cache - cache a cached DF (zstd level 1)              226            232 
          8          8.9         112.8       1.3X
-Arrow cache - cache a cached DF (zstd level 3)              226            245 
         23          8.8         113.0       1.2X
+Default cache - cache a cached DF                           427            458 
         28          4.7         213.3       1.0X
+Default cache - cache a cached DF (uncompressed)            207            229 
         32          9.7         103.4       2.1X
+Arrow cache - cache a cached DF (zero-copy)                 123            143 
         16         16.3          61.3       3.5X
+Arrow cache - cache a cached DF (zstd level -1)             287            296 
         17          7.0         143.5       1.5X
+Arrow cache - cache a cached DF (zstd level 1)              297            308 
         17          6.7         148.5       1.4X
+Arrow cache - cache a cached DF (zstd level 3)              310            316 
          3          6.4         155.2       1.4X
 
 
 
================================================================================================
 Cache with column pruning (select 1 of 20 columns)
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 25.0.4+7-LTS on Linux 6.17.0-1020-azure
-Intel(R) Xeon(R) 6973P-C
+OpenJDK 64-Bit Server VM 25.0.5.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
 Cache 5M rows, select 1 column:                Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
-----------------------------------------------------------------------------------------------------------------------------
-Default cache - select 1 of 20 columns                  8543           8567    
      34          0.6        1708.7       1.0X
-Default cache - select 1 of 20 (uncompressed)           3281           3297    
      23          1.5         656.2       2.6X
-Arrow cache - select 1 of 20                            4244           4314    
     100          1.2         848.7       2.0X
-Arrow cache - select 1 of 20 (zstd level -1)            5699           5727    
      40          0.9        1139.7       1.5X
-Arrow cache - select 1 of 20 (zstd level 1)             5691           5703    
      18          0.9        1138.1       1.5X
-Arrow cache - select 1 of 20 (zstd level 3)             5924           6051    
     180          0.8        1184.8       1.4X
+Default cache - select 1 of 20 columns                 12339          12457    
     166          0.4        2467.9       1.0X
+Default cache - select 1 of 20 (uncompressed)           6253           6402    
     212          0.8        1250.5       2.0X
+Arrow cache - select 1 of 20                            7279           7453    
     246          0.7        1455.9       1.7X
+Arrow cache - select 1 of 20 (zstd level -1)            8967           9002    
      50          0.6        1793.3       1.4X
+Arrow cache - select 1 of 20 (zstd level 1)             9149           9415    
     377          0.5        1829.7       1.3X
+Arrow cache - select 1 of 20 (zstd level 3)             9647           9723    
     108          0.5        1929.4       1.3X
+
+
+================================================================================================
+Cache with column pruning (sum 1 of 50 columns)
+================================================================================================
+
+OpenJDK 64-Bit Server VM 25.0.5.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
+Sum 1 of 50 columns, 1000000 rows:        Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
+------------------------------------------------------------------------------------------------------------------------
+Default cache                                        74            121         
 33         13.4          74.4       1.0X
+Default cache (uncompressed)                         65             85         
 19         15.5          64.7       1.2X
+Arrow cache                                          53             64         
 15         18.9          53.0       1.4X
+Arrow cache (zstd level -1)                          62             73         
 22         16.2          61.8       1.2X
+Arrow cache (zstd level 1)                           61             76         
 24         16.5          60.7       1.2X
+Arrow cache (zstd level 3)                           60             67         
 20         16.7          60.0       1.2X
 
 
 
diff --git a/sql/core/benchmarks/ArrowCacheBenchmark-results.txt 
b/sql/core/benchmarks/ArrowCacheBenchmark-results.txt
index fd3f1a83fefe..2c7366f3d4db 100644
--- a/sql/core/benchmarks/ArrowCacheBenchmark-results.txt
+++ b/sql/core/benchmarks/ArrowCacheBenchmark-results.txt
@@ -6,80 +6,109 @@ Arrow Cache vs Default Cache
 Cache primitive types
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1019-azure
 AMD EPYC 7763 64-Core Processor
 Cache 5M rows with primitives:               Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
---------------------------------------------------------------------------------------------------------------------------
-Default cache - write + read                          1778           1868      
   127          2.8         355.6       1.0X
-Default cache - write + read (uncompressed)           1138           1151      
    18          4.4         227.6       1.6X
-Arrow cache - write + read                            1328           1339      
    16          3.8         265.5       1.3X
-Arrow cache - write + read (zstd level -1)            1802           1875      
   104          2.8         360.3       1.0X
-Arrow cache - write + read (zstd level 1)             1804           1831      
    38          2.8         360.8       1.0X
-Arrow cache - write + read (zstd level 3)             1875           1918      
    61          2.7         375.0       0.9X
+Default cache - write + read                          2185           2349      
   231          2.3         437.1       1.0X
+Default cache - write + read (uncompressed)           1551           1591      
    56          3.2         310.3       1.4X
+Arrow cache - write + read                            1855           1883      
    39          2.7         371.0       1.2X
+Arrow cache - write + read (zstd level -1)            2236           2279      
    60          2.2         447.3       1.0X
+Arrow cache - write + read (zstd level 1)             2350           2366      
    23          2.1         470.0       0.9X
+Arrow cache - write + read (zstd level 3)             2464           2503      
    56          2.0         492.8       0.9X
 
 
 
================================================================================================
 Cache then filter
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1019-azure
 AMD EPYC 7763 64-Core Processor
 Cache 5M rows, then filter:               Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
------------------------------------------------------------------------------------------------------------------------
-Default cache - filter                             1489           1524         
 50          3.4         297.8       1.0X
-Default cache - filter (uncompressed)              1280           1321         
 58          3.9         256.0       1.2X
-Arrow cache - filter                               1387           1395         
 11          3.6         277.5       1.1X
-Arrow cache - filter (zstd level -1)               1769           1773         
  6          2.8         353.8       0.8X
-Arrow cache - filter (zstd level 1)                1867           1873         
  8          2.7         373.3       0.8X
-Arrow cache - filter (zstd level 3)                1900           1906         
  8          2.6         380.0       0.8X
+Default cache - filter                             2058           2070         
 16          2.4         411.6       1.0X
+Default cache - filter (uncompressed)              1795           1815         
 27          2.8         359.0       1.1X
+Arrow cache - filter                               1949           2008         
 83          2.6         389.9       1.1X
+Arrow cache - filter (zstd level -1)               2373           2398         
 35          2.1         474.6       0.9X
+Arrow cache - filter (zstd level 1)                2396           2434         
 55          2.1         479.1       0.9X
+Arrow cache - filter (zstd level 3)                2596           2631         
 48          1.9         519.3       0.8X
 
 
 
================================================================================================
 Cache columnar input (Parquet)
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1019-azure
 AMD EPYC 7763 64-Core Processor
 Cache 2M rows from Parquet:                    Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
-----------------------------------------------------------------------------------------------------------------------------
-Default cache - columnar input                          1470           1532    
      87          1.4         735.2       1.0X
-Default cache - columnar input (uncompressed)           1309           1411    
     145          1.5         654.5       1.1X
-Arrow cache - columnar input                            1313           1345    
      46          1.5         656.3       1.1X
-Arrow cache - columnar input (zstd level -1)            1509           1530    
      28          1.3         754.7       1.0X
-Arrow cache - columnar input (zstd level 1)             1522           1530    
      12          1.3         760.8       1.0X
-Arrow cache - columnar input (zstd level 3)             1568           1589    
      30          1.3         784.1       0.9X
+Default cache - columnar input                          2228           2258    
      43          0.9        1114.0       1.0X
+Default cache - columnar input (uncompressed)           2059           2098    
      56          1.0        1029.4       1.1X
+Arrow cache - columnar input                            2226           2234    
      13          0.9        1112.8       1.0X
+Arrow cache - columnar input (zstd level -1)            2318           2398    
     112          0.9        1159.1       1.0X
+Arrow cache - columnar input (zstd level 1)             2439           2543    
     147          0.8        1219.5       0.9X
+Arrow cache - columnar input (zstd level 3)             2767           2814    
      67          0.7        1383.5       0.8X
+
+
+================================================================================================
+Cache a shuffled query
+================================================================================================
+
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
+Cache 5M rows after a shuffle:            Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
+------------------------------------------------------------------------------------------------------------------------
+Default cache - shuffled input                     2235           2250         
 22          2.2         446.9       1.0X
+Arrow cache - shuffled input                       2031           2033         
  4          2.5         406.1       1.1X
+Arrow cache - shuffled input (AQE off)             1740           1742         
  3          2.9         348.0       1.3X
 
 
 
================================================================================================
 Re-cache Arrow cached data (zero-copy test)
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1019-azure
 AMD EPYC 7763 64-Core Processor
 Re-cache 2M rows (zero-copy):                     Best Time(ms)   Avg Time(ms) 
  Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
--------------------------------------------------------------------------------------------------------------------------------
-Default cache - cache a cached DF                           382            418 
         39          5.2         191.1       1.0X
-Default cache - cache a cached DF (uncompressed)            191            201 
         14         10.4          95.7       2.0X
-Arrow cache - cache a cached DF (zero-copy)                 123            135 
         13         16.3          61.3       3.1X
-Arrow cache - cache a cached DF (zstd level -1)             311            313 
          2          6.4         155.5       1.2X
-Arrow cache - cache a cached DF (zstd level 1)              321            326 
          4          6.2         160.4       1.2X
-Arrow cache - cache a cached DF (zstd level 3)              336            338 
          1          6.0         167.8       1.1X
+Default cache - cache a cached DF                           388            409 
         18          5.2         193.9       1.0X
+Default cache - cache a cached DF (uncompressed)            194            213 
         32         10.3          96.8       2.0X
+Arrow cache - cache a cached DF (zero-copy)                 126            134 
          7         15.9          62.8       3.1X
+Arrow cache - cache a cached DF (zstd level -1)             293            307 
         28          6.8         146.4       1.3X
+Arrow cache - cache a cached DF (zstd level 1)              302            315 
         14          6.6         150.9       1.3X
+Arrow cache - cache a cached DF (zstd level 3)              315            334 
         29          6.4         157.3       1.2X
 
 
 
================================================================================================
 Cache with column pruning (select 1 of 20 columns)
 
================================================================================================
 
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1019-azure
 AMD EPYC 7763 64-Core Processor
 Cache 5M rows, select 1 column:                Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
 
-----------------------------------------------------------------------------------------------------------------------------
-Default cache - select 1 of 20 columns                  9740           9775    
      49          0.5        1948.1       1.0X
-Default cache - select 1 of 20 (uncompressed)           4030           4085    
      78          1.2         805.9       2.4X
-Arrow cache - select 1 of 20                            5177           5227    
      72          1.0        1035.3       1.9X
-Arrow cache - select 1 of 20 (zstd level -1)            8122           8158    
      52          0.6        1624.3       1.2X
-Arrow cache - select 1 of 20 (zstd level 1)             8132           8152    
      29          0.6        1626.4       1.2X
-Arrow cache - select 1 of 20 (zstd level 3)             8531           8575    
      62          0.6        1706.3       1.1X
+Default cache - select 1 of 20 columns                 12254          12336    
     115          0.4        2450.8       1.0X
+Default cache - select 1 of 20 (uncompressed)           6585           6600    
      21          0.8        1316.9       1.9X
+Arrow cache - select 1 of 20                            6974           7032    
      82          0.7        1394.8       1.8X
+Arrow cache - select 1 of 20 (zstd level -1)            9243           9310    
      95          0.5        1848.6       1.3X
+Arrow cache - select 1 of 20 (zstd level 1)             9197           9317    
     169          0.5        1839.4       1.3X
+Arrow cache - select 1 of 20 (zstd level 3)             9577           9662    
     120          0.5        1915.5       1.3X
+
+
+================================================================================================
+Cache with column pruning (sum 1 of 50 columns)
+================================================================================================
+
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1019-azure
+AMD EPYC 7763 64-Core Processor
+Sum 1 of 50 columns, 1000000 rows:        Best Time(ms)   Avg Time(ms)   
Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
+------------------------------------------------------------------------------------------------------------------------
+Default cache                                        67             94         
 31         14.9          67.3       1.0X
+Default cache (uncompressed)                         65             78         
 20         15.3          65.2       1.0X
+Arrow cache                                          55             72         
 22         18.2          54.8       1.2X
+Arrow cache (zstd level -1)                          64             81         
 27         15.7          63.8       1.1X
+Arrow cache (zstd level 1)                           63             79         
 25         15.8          63.4       1.1X
+Arrow cache (zstd level 3)                           63             77         
 30         15.9          62.9       1.1X
 
 
 
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/ArrowCacheBenchmark.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/ArrowCacheBenchmark.scala
index 7df7e97ecb25..0302ddc06b6f 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/ArrowCacheBenchmark.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/benchmark/ArrowCacheBenchmark.scala
@@ -465,6 +465,50 @@ object ArrowCacheBenchmark extends SqlBasedBenchmark {
     }
   }
 
+  private def cacheShuffledQuery(): Unit = {
+    val numRows = 5000000 // 5M rows
+    // AQE plans a cached query that has an exchange. For a serializer that 
takes columnar input,
+    // like the Arrow one, its rows then reach the cache through 
RowToColumnarExec at the end of
+    // the cached plan, a path that the other sections do not take: their 
queries have no exchange,
+    // or read Parquet, which is columnar already. The Default serializer 
takes rows. Each case
+    // times the cache build, including the shuffle, after creating its 
session.
+    runBenchmark("Cache a shuffled query") {
+      val benchmark = new Benchmark("Cache 5M rows after a shuffle", numRows, 
output = output)
+
+      def addShuffledCase(name: String, serializer: String)(
+          configure: SparkSession => Unit): Unit = {
+        benchmark.addTimerCase(name) { timer =>
+          val spark = createFreshSession(serializer)
+          try {
+            configure(spark)
+            val df = spark.range(numRows).repartition(1).selectExpr(
+              "id as int_col",
+              "id * 2L as long_col",
+              "cast(id as double) as double_col"
+            )
+            timer.startTiming()
+            df.cache()
+            df.count() // Materialize cache
+            timer.stopTiming()
+            df.unpersist(blocking = true)
+          } finally {
+            spark.stop()
+          }
+        }
+      }
+
+      val arrow = classOf[ArrowCachedBatchSerializer].getName
+      addShuffledCase("Default cache - shuffled input",
+        
"org.apache.spark.sql.execution.columnar.DefaultCachedBatchSerializer")(_ => ())
+      addShuffledCase("Arrow cache - shuffled input", arrow)(_ => ())
+      // Without AQE the same query reaches the Arrow serializer as rows, 
without RowToColumnarExec.
+      addShuffledCase("Arrow cache - shuffled input (AQE off)", arrow) { spark 
=>
+        spark.conf.set(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key, "false")
+      }
+      benchmark.run()
+    }
+  }
+
   private def recacheArrowData(): Unit = {
     val numRows = 2000000 // 2M rows
     runBenchmark("Re-cache Arrow cached data (zero-copy test)") {
@@ -853,6 +897,7 @@ object ArrowCacheBenchmark extends SqlBasedBenchmark {
       cachePrimitiveTypes()
       cacheWithFilters()
       cacheColumnarInput()
+      cacheShuffledQuery()
       recacheArrowData()
       columnPruning()
       columnPruningWideTable()


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to