kazuyukitanimura commented on code in PR #6419:
URL: https://github.com/apache/datafusion-comet/pull/6419#discussion_r4139039797


##########
spark/src/test/scala/org/apache/spark/CometTaskMemoryManagerSuite.scala:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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
+
+import java.util.Properties
+
+import org.apache.logging.log4j.{Level, LogManager}
+import org.apache.logging.log4j.core.{LogEvent, LoggerContext}
+import org.apache.spark.executor.TaskMetrics
+import org.apache.spark.memory.{TaskMemoryManager, TestMemoryManager}
+
+class CometTaskMemoryManagerSuite extends SparkFunSuite {
+
+  test("partial and zero grants log nothing at INFO or above") {
+    // Spark refuses native reservations routinely under memory pressure, each 
time with one of
+    // these.
+    withTaskMemoryManager { _ =>
+      val manager = new CometTaskMemoryManager(1L, 0L)
+      val events = logEvents(Level.INFO) {
+        assert(manager.acquireMemory(768L) == 768L)
+        assert(manager.acquireMemory(512L) == 256L)
+        assert(manager.acquireMemory(128L) == 0L)
+      }
+      assert(events.isEmpty, 
events.map(_.getMessage.getFormattedMessage).mkString("\n"))
+      manager.releaseMemory(1024L)
+    }
+  }
+
+  test("a partial grant is logged at DEBUG, without the task's memory usage 
dump") {

Review Comment:
   NativeMemoryConsumer.toString on branch-1.0 still uses 
String.format("NativeMemoryConsumer(id=%)", id), which throws 
UnknownFormatConversionException. #5398 fixed it on main but it never came back 
to branch-1.0. This test turns on the TaskMemoryManager logger at DEBUG. Spark 
then logs Task {}  
    acquired {} for {} with our consumer as an argument, so the captured events 
include log4j2's fallback text, 
[!!!…=>java.util.UnknownFormatConversionException:Conversion = ')'!!!]. The 
test still passes, but users who turn on TaskMemoryManager DEBUG logging to 
debug native memory would see the same thing. Could you open a separate 
branch-1.0 backport for #5398 and link it here?



-- 
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