sunchao commented on code in PR #5392:
URL: https://github.com/apache/datafusion-comet/pull/5392#discussion_r3815919434


##########
spark/src/test/scala/org/apache/spark/sql/comet/execution/shuffle/CometNativeShuffleInputRDDSuite.scala:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.spark.sql.comet.execution.shuffle
+
+import org.apache.spark.serializer.JavaSerializer
+import org.apache.spark.sql.CometTestBase
+
+/**
+ * Ensure that serialized RDD does not overflow in size with a very large 
number of partitions
+ * Lives in the `execution.shuffle` package so it can construct the 
`private[shuffle]`
+ * [[CometNativeShuffleInputRDD]] directly.
+ */
+class CometNativeShuffleInputRDDSuite extends CometTestBase {
+
+  test("serialized RDD size is independent of partition count") {
+    val sc = spark.sparkContext
+    val ser = new JavaSerializer(sc.getConf).newInstance()
+
+    // One scan key with a 1KB blob per map partition. Pre-fix the whole array 
serializes into the
+    // RDD, so 10000 partitions add ~10MB versus 10.
+    def buildRDD(numPartitions: Int): CometNativeShuffleInputRDD = {
+      val perPartitionByKey =
+        Map("scan-0" -> Array.fill(numPartitions)(new Array[Byte](1024)))
+      new CometNativeShuffleInputRDD(
+        sc,
+        inputRDDs = Seq.empty,
+        numPartitionsParam = numPartitions,
+        shuffleScanIndices = Set.empty,
+        perPartitionByKey = perPartitionByKey)
+    }
+
+    val smallSize = ser.serialize(buildRDD(10)).limit()
+    val large = buildRDD(10000)
+    val largeSize = ser.serialize(large).limit()

Review Comment:
   [P2] Exercise the actual shuffle task binary
   
   Could this also construct a native shuffle dependency and compare the 
serialized size of `(rdd, shuffleDependency)` for 10 and 10,000 partitions? 
That is what Spark broadcasts for a shuffle-map stage. Before this fix, the 
large map lived under `CometShuffleDependency.nativeShuffleSpec.execContext`, 
not on the thin RDD. In an isolated Spark serialization probe, restoring that 
dependency leak left the RDD at 880 bytes while the pair grew from 13,322 to 
10,342,982 bytes. The current RDD-only assertion therefore stays green if those 
guards regress. Testing the actual pair would protect the reported 2GB failure 
without requiring a 2GB allocation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to