You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "holdenk (via GitHub)" <gi...@apache.org> on 2026/09/10 11:28:54 UTC

[PR] [SPARK-59407][UI][HISTORY] Improve compressed line handling in Spark History server [spark]

holdenk opened a new pull request, #58700:
URL: https://github.com/apache/spark/pull/58700

   ### What changes were proposed in this pull request?
   Skip excessively long compressed lines.
   
   ### Why are the changes needed?
   Individual long compressed lines can cause slowness loading a previous Spark job.
   
   
   ### Does this PR introduce _any_ user-facing change?
   New configurable param
   
   ### How was this patch tested?
   New test
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Claude and cursor


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59407][UI][HISTORY] Improve compressed line handling in Spark History server [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #58700:
URL: https://github.com/apache/spark/pull/58700#discussion_r3985238683


##########
core/src/main/scala/org/apache/spark/internal/config/History.scala:
##########
@@ -165,6 +165,19 @@ private[spark] object History {
       .bytesConf(ByteUnit.BYTE)
       .createWithDefaultString("1m")
 
+  val EVENT_LOG_MAX_LINE_LENGTH =
+    ConfigBuilder("spark.history.fs.eventLog.maxLineLength")
+      .doc("Maximum length of a single event log line during replay. Lines longer than " +
+        "this are skipped with a warning instead of being read into memory, bounding the " +
+        "memory replay can use when an event log is corrupt or unexpectedly large. Setting " +
+        "this to 0 or a negative value disables the limit. " +
+        "Introduced in 4.3.0; also available in 3.5.10, 4.0.5, 4.1.4 and 4.2.1; and in " +
+        "all versions after 4.3.0.")
+      .version("4.3.0")
+      .withBindingPolicy(ConfigBindingPolicy.NOT_APPLICABLE)
+      .bytesConf(ByteUnit.BYTE)
+      .createWithDefaultString("512m")

Review Comment:
   Can we make this as createOptional since we plan to backport to old branches?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59407][UI][HISTORY] Improve compressed line handling in Spark History server [spark]

Posted by "holdenk (via GitHub)" <gi...@apache.org>.
holdenk commented on code in PR #58700:
URL: https://github.com/apache/spark/pull/58700#discussion_r4035472917


##########
core/src/main/scala/org/apache/spark/internal/config/History.scala:
##########
@@ -165,6 +165,19 @@ private[spark] object History {
       .bytesConf(ByteUnit.BYTE)
       .createWithDefaultString("1m")
 
+  val EVENT_LOG_MAX_LINE_LENGTH =
+    ConfigBuilder("spark.history.fs.eventLog.maxLineLength")
+      .doc("Maximum length of a single event log line during replay. Lines longer than " +
+        "this are skipped with a warning instead of being read into memory, bounding the " +
+        "memory replay can use when an event log is corrupt or unexpectedly large. Setting " +
+        "this to 0 or a negative value disables the limit. " +
+        "Introduced in 4.3.0; also available in 3.5.10, 4.0.5, 4.1.4 and 4.2.1; and in " +
+        "all versions after 4.3.0.")
+      .version("4.3.0")
+      .withBindingPolicy(ConfigBindingPolicy.NOT_APPLICABLE)
+      .bytesConf(ByteUnit.BYTE)
+      .createWithDefaultString("512m")

Review Comment:
   We could, although I think a default of 512mb for a single line is a "sane" default even for backporting. I think any circumstance where a single line is greater than 512mb the right thing to do is to reject it.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59407][UI] Improve compressed line handling in Spark History server [spark]

Posted by "asf-gitbox-commits (via GitHub)" <gi...@apache.org>.
asf-gitbox-commits closed pull request #58700: [SPARK-59407][UI] Improve compressed line handling in Spark History server
URL: https://github.com/apache/spark/pull/58700


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59407][UI][HISTORY] Improve compressed line handling in Spark History server [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #58700:
URL: https://github.com/apache/spark/pull/58700#discussion_r3985281212


##########
core/src/main/scala/org/apache/spark/internal/config/History.scala:
##########
@@ -165,6 +165,19 @@ private[spark] object History {
       .bytesConf(ByteUnit.BYTE)
       .createWithDefaultString("1m")
 
+  val EVENT_LOG_MAX_LINE_LENGTH =
+    ConfigBuilder("spark.history.fs.eventLog.maxLineLength")
+      .doc("Maximum length of a single event log line during replay. Lines longer than " +
+        "this are skipped with a warning instead of being read into memory, bounding the " +
+        "memory replay can use when an event log is corrupt or unexpectedly large. Setting " +
+        "this to 0 or a negative value disables the limit. " +
+        "Introduced in 4.3.0; also available in 3.5.10, 4.0.5, 4.1.4 and 4.2.1; and in " +
+        "all versions after 4.3.0.")
+      .version("4.3.0")
+      .withBindingPolicy(ConfigBindingPolicy.NOT_APPLICABLE)
+      .bytesConf(ByteUnit.BYTE)
+      .createWithDefaultString("512m")

Review Comment:
   Can we actually make this conf optional too? Since we're backporting them to old branches.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59407][UI][HISTORY] Improve compressed line handling in Spark History server [spark]

Posted by "holdenk (via GitHub)" <gi...@apache.org>.
holdenk commented on code in PR #58700:
URL: https://github.com/apache/spark/pull/58700#discussion_r4042285017


##########
core/src/main/scala/org/apache/spark/internal/config/History.scala:
##########
@@ -165,6 +165,19 @@ private[spark] object History {
       .bytesConf(ByteUnit.BYTE)
       .createWithDefaultString("1m")
 
+  val EVENT_LOG_MAX_LINE_LENGTH =
+    ConfigBuilder("spark.history.fs.eventLog.maxLineLength")
+      .doc("Maximum length of a single event log line during replay. Lines longer than " +
+        "this are skipped with a warning instead of being read into memory, bounding the " +
+        "memory replay can use when an event log is corrupt or unexpectedly large. Setting " +
+        "this to 0 or a negative value disables the limit. " +
+        "Introduced in 4.3.0; also available in 3.5.10, 4.0.5, 4.1.4 and 4.2.1; and in " +
+        "all versions after 4.3.0.")
+      .version("4.3.0")
+      .withBindingPolicy(ConfigBindingPolicy.NOT_APPLICABLE)
+      .bytesConf(ByteUnit.BYTE)
+      .createWithDefaultString("512m")

Review Comment:
   So I switched it to multiply by two so it matches bytes, also thinking about this I think it's probably safe to backport with a 512mb default lime limit? Like it is a behavior change on the history server true, but previously if we encountered a 512mb line in the history server log files it's not like it would have worked well.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59407][UI][HISTORY] Improve compressed line handling in Spark History server [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #58700:
URL: https://github.com/apache/spark/pull/58700#discussion_r3985271016


##########
core/src/main/scala/org/apache/spark/internal/config/History.scala:
##########
@@ -165,6 +165,19 @@ private[spark] object History {
       .bytesConf(ByteUnit.BYTE)
       .createWithDefaultString("1m")
 
+  val EVENT_LOG_MAX_LINE_LENGTH =
+    ConfigBuilder("spark.history.fs.eventLog.maxLineLength")
+      .doc("Maximum length of a single event log line during replay. Lines longer than " +
+        "this are skipped with a warning instead of being read into memory, bounding the " +
+        "memory replay can use when an event log is corrupt or unexpectedly large. Setting " +
+        "this to 0 or a negative value disables the limit. " +
+        "Introduced in 4.3.0; also available in 3.5.10, 4.0.5, 4.1.4 and 4.2.1; and in " +
+        "all versions after 4.3.0.")
+      .version("4.3.0")
+      .withBindingPolicy(ConfigBindingPolicy.NOT_APPLICABLE)
+      .bytesConf(ByteUnit.BYTE)
+      .createWithDefaultString("512m")

Review Comment:
   This is declared as a byte size (`bytesConf`, `512m`), but the cap is enforced as a UTF-16 character count downstream — `sb.length() < maxLineLength` in `ReplayListenerBus.boundedLines`. So for multi-byte UTF-8 the effective byte threshold is larger than configured, and a retained line can hold up to ~2x the configured number of bytes in heap (Java `char` is 2 bytes).
   
   The class parameter doc already says "characters"; worth saying the same in this entry's `.doc(...)` and in the `docs/monitoring.md` row so the documented contract matches enforcement.



##########
core/src/main/scala/org/apache/spark/scheduler/ReplayListenerBus.scala:
##########
@@ -56,10 +66,79 @@ private[spark] class ReplayListenerBus extends SparkListenerBus with Logging {
       sourceName: String,
       maybeTruncated: Boolean = false,
       eventsFilter: ReplayEventsFilter = SELECT_ALL_FILTER): Boolean = {
-    val lines = Source.fromInputStream(logData)(Codec.UTF8).getLines()
+    val lines = boundedLines(logData, sourceName)
     replay(lines, sourceName, maybeTruncated, eventsFilter)
   }
 
+  /**
+   * Reads '\n'-terminated lines like Source.getLines(), but never materializes more than
+   * [[maxLineLength]] characters of a single line. An over-long line is drained and skipped

Review Comment:
   A `[[...]]` wiki-link only resolves to documented members, and `maxLineLength` is a non-`val` constructor parameter, which Scaladoc doesn't document — so this renders as literal text rather than a link.
   
   ```suggestion
      * `maxLineLength` characters of a single line. An over-long line is drained and skipped
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org