You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2025/09/18 07:08:39 UTC
[PR] [SPARK-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
pan3793 opened a new pull request, #52382:
URL: https://github.com/apache/spark/pull/52382
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Core idea:
1. Change the log replay thread pool to have a bounded queue, and block task submission when the queue is full.
Currently, the log replay thread pool uses an unbound queue, when there are a large number (e.g., millions) of event logs under `spark.history.fs.logDirectory`, all tasks will be queued at the thread pool queue without blocking the scanning thread, and in the next schedule, queue again ...
https://stackoverflow.com/questions/4521983/java-executorservice-that-blocks-on-submission-after-a-certain-queue-size
2. Move log compaction to a dedicated thread pool.
Replaying and compacting are different types of workloads, isolating them from each other could improve the resource utilization.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
Improve performance and reduce memory usage on the SHS bootstrap with empty KV cache, when there are tons of event logs.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No functionality changes.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
Tested on an internal cluster, starting SHS with an empty `spark.history.store.path` and ~650k event logs under `spark.history.fs.logDirectory`, the related configs are
```
spark.history.fs.cleaner.maxNum 650000
spark.history.fs.logDirectory hdfs://foo/spark2-history
spark.history.fs.update.interval 5s
spark.history.provider org.apache.spark.deploy.history.FsHistoryProvider
spark.history.store.maxDiskUsage 100GB
spark.history.store.path /foo/bar/historyStore
spark.history.fs.numReplayThreads 64
spark.history.fs.numCompactThreads 4
spark.history.store.hybridStore.enabled true
spark.history.store.hybridStore.maxMemoryUsage 16g
spark.history.store.hybridStore.diskBackend ROCKSDB
```
- `spark.history.store.path` is configured to an HDD path
- we disable `spark.eventLog.rolling.enabled` so `numCompactThreads` has no heavy work
It's much faster than before, and metrics show better CPU utilization and lower memory usage.
<img width="2546" height="480" alt="bf51f797a11527ce82036669f96cf50b" src="https://github.com/user-attachments/assets/4db521b0-cf1c-4b93-a06d-27fdaf1ccec4" />
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
No.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2360055650
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path, SafeModeAction}
import org.apache.hadoop.hdfs.DistributedFileSystem
import org.apache.hadoop.security.AccessControlException
+import org.apache.hadoop.util.BlockingThreadPoolExecutorService
Review Comment:
Well, I'm not sure this is a good decision.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357789748
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -487,15 +502,16 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
var count: Int = 0
try {
val newLastScanTime = clock.getTimeMillis()
- logDebug(s"Scanning $logDir with lastScanTime==$lastScanTime")
+ logInfo(log"Scanning ${MDC(HISTORY_DIR, logDir)} with " +
+ log"lastScanTime=${MDC(LAST_SCAN_TIME, lastScanTime)}")
Review Comment:
I escalated this log level to info, it's not noisy and is relatively important for the admin to understand the scanning frequency
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357832416
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -612,11 +628,11 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
}
if (updated.nonEmpty) {
- logDebug(s"New/updated attempts found: ${updated.size} ${updated.map(_.rootPath)}")
+ logInfo(log"New/updated attempts found: ${MDC(NUM_ATTEMPT, updated.size)}")
Review Comment:
the `${updated.size}` is useful, but the `${updated.map(_.rootPath)}` is dangerous, it produces a huge string that may cause OOM.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357832416
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -612,11 +628,11 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
}
if (updated.nonEmpty) {
- logDebug(s"New/updated attempts found: ${updated.size} ${updated.map(_.rootPath)}")
+ logInfo(log"New/updated attempts found: ${MDC(NUM_ATTEMPT, updated.size)}")
Review Comment:
the number is useful, but the `${updated.map(_.rootPath)}` is dangerous, it produces a huge string that may cause OOM.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357873549
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path, SafeModeAction}
import org.apache.hadoop.hdfs.DistributedFileSystem
import org.apache.hadoop.security.AccessControlException
+import org.apache.hadoop.util.BlockingThreadPoolExecutorService
Review Comment:
this class is marked as `@Private`, but the API has been stable since 2016, so it should be low risk to use directly.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "peter-toth (via GitHub)" <gi...@apache.org>.
peter-toth commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2360214344
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path, SafeModeAction}
import org.apache.hadoop.hdfs.DistributedFileSystem
import org.apache.hadoop.security.AccessControlException
+import org.apache.hadoop.util.BlockingThreadPoolExecutorService
Review Comment:
The idea and implementation looks good to me, but I share the concerns of @dongjoon-hyun .
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357796915
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -788,7 +804,7 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
// triggering another task for compaction task only if it succeeds
if (succeeded) {
- submitLogProcessTask(rootPath) { () => compact(reader) }
+ submitLogProcessTask(rootPath, compactExecutor) { () => compact(reader) }
Review Comment:
It's actually a MUST change. Otherwise, submitting a task to the self pool will cause a deadlock if the queue is full.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357796915
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -788,7 +804,7 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
// triggering another task for compaction task only if it succeeds
if (succeeded) {
- submitLogProcessTask(rootPath) { () => compact(reader) }
+ submitLogProcessTask(rootPath, compactExecutor) { () => compact(reader) }
Review Comment:
It's actually a MUST change. Otherwise, submitting a task to the self pool will cause a deadlock when the queue is full.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #52382:
URL: https://github.com/apache/spark/pull/52382#issuecomment-3305815702
cc @dongjoon-hyun @LuciferYang @mridulm @wangyum
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2360414658
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path, SafeModeAction}
import org.apache.hadoop.hdfs.DistributedFileSystem
import org.apache.hadoop.security.AccessControlException
+import org.apache.hadoop.util.BlockingThreadPoolExecutorService
Review Comment:
I understand the reasoning. However, I disagree with the point of cutting off the Hadoop deps. If that's tricky now, it will be the same in the end.
Without moving forward, we need to check the following.
1. Can we borrow `Private`-scope code in Spark side stably without increasing further maintenance burden?
2. Can we ask Apache Hadoop community to expose that class officially? This will remove our forked code at that time.
Historically, we spent lots of efforts to migrate to `Hadoop Client` to avoid this kind of dependencies issue. I don't think both the Apache Spark and Apache Hadoop community wants to have a kind of hard dependencies again.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357789748
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -487,15 +502,16 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
var count: Int = 0
try {
val newLastScanTime = clock.getTimeMillis()
- logDebug(s"Scanning $logDir with lastScanTime==$lastScanTime")
+ logInfo(log"Scanning ${MDC(HISTORY_DIR, logDir)} with " +
+ log"lastScanTime=${MDC(LAST_SCAN_TIME, lastScanTime)}")
Review Comment:
I escalated this log level to info, it's not noisy and is relatively important for the user to understand the scanning frequency
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2366746788
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path, SafeModeAction}
import org.apache.hadoop.hdfs.DistributedFileSystem
import org.apache.hadoop.security.AccessControlException
+import org.apache.hadoop.util.BlockingThreadPoolExecutorService
Review Comment:
BTW, I also verified the updated code on the prod env, and it has the same effect as the first version.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357785490
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -487,15 +502,16 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
var count: Int = 0
try {
val newLastScanTime = clock.getTimeMillis()
- logDebug(s"Scanning $logDir with lastScanTime==$lastScanTime")
+ logInfo(log"Scanning ${MDC(HISTORY_DIR, logDir)} with " +
+ log"lastScanTime=${MDC(LAST_SCAN_TIME, lastScanTime)}")
// Mark entries that are processing as not stale. Such entries do not have a chance to be
// updated with the new 'lastProcessed' time and thus any entity that completes processing
// right after this check and before the check for stale entities will be identified as stale
// and will be deleted from the UI until the next 'checkForLogs' run.
val notStale = mutable.HashSet[String]()
val updated = Option(fs.listStatus(new Path(logDir)))
- .map(_.toImmutableArraySeq).getOrElse(Nil)
+ .map(_.toImmutableArraySeq).getOrElse(Seq.empty)
Review Comment:
IDEA can not highlight without this change.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357814745
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -209,7 +211,20 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
*/
private val replayExecutor: ExecutorService = {
if (!Utils.isTesting) {
- ThreadUtils.newDaemonFixedThreadPool(NUM_PROCESSING_THREADS, "log-replay-executor")
+ BlockingThreadPoolExecutorService.newInstance(
+ numReplayThreads, 1024, 60L, TimeUnit.SECONDS, "log-replay-executor")
Review Comment:
1024 - queue size, since listing logDir may take some times, it's better to allow some tasks to be queued before starting the next round
60s, core thread idle time
I don't think it's necessary to expose these configs to users, but I'm open to different ideas.
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -209,7 +211,20 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
*/
private val replayExecutor: ExecutorService = {
if (!Utils.isTesting) {
- ThreadUtils.newDaemonFixedThreadPool(NUM_PROCESSING_THREADS, "log-replay-executor")
+ BlockingThreadPoolExecutorService.newInstance(
+ numReplayThreads, 1024, 60L, TimeUnit.SECONDS, "log-replay-executor")
Review Comment:
1024 - queue size, since listing logDir may take some times, it's better to allow some tasks to be queued before starting the next round
60s - core thread idle time
I don't think it's necessary to expose these configs to users, but I'm open to different ideas.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2360296059
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path, SafeModeAction}
import org.apache.hadoop.hdfs.DistributedFileSystem
import org.apache.hadoop.security.AccessControlException
+import org.apache.hadoop.util.BlockingThreadPoolExecutorService
Review Comment:
@dongjoon-hyun @peter-toth thanks for the review, I understand your concerns, let me explain my thoughts.
my initial idea is to implement such a policy
```scala
val BLOCK_PLOCY = new RejectedExecutionHandler() {
override def rejectedExecution(r: Runnable, executor: ThreadPoolExecutor): Unit = {
executor.getQueue.put(r)
}
}
```
but after searching on Stack Overflow, this seems to be trickier than I thought
https://stackoverflow.com/questions/3446011/threadpoolexecutor-block-when-its-queue-is-full/3518588#3518588
https://stackoverflow.com/questions/4521983/java-executorservice-that-blocks-on-submission-after-a-certain-queue-size
Given that Hadoop already has a solid (I suppose so) and stable implementation, I eventually chose to use it directly. In the worst cases, for example, Hadoop breaks the API, or Spark decides to cut off the Hadoop deps in the future (both should be rare to happen), we can fork the code from Hadoop.
--
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-53631][CORE] Optimize memory and perf on SHS bootstrap [spark]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #52382: [SPARK-53631][CORE] Optimize memory and perf on SHS bootstrap
URL: https://github.com/apache/spark/pull/52382
--
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-53631][CORE] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357814745
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -209,7 +211,20 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
*/
private val replayExecutor: ExecutorService = {
if (!Utils.isTesting) {
- ThreadUtils.newDaemonFixedThreadPool(NUM_PROCESSING_THREADS, "log-replay-executor")
+ BlockingThreadPoolExecutorService.newInstance(
+ numReplayThreads, 1024, 60L, TimeUnit.SECONDS, "log-replay-executor")
Review Comment:
1024 - queue size, since listing logDir may take some time, it's better to allow some tasks to be queued before starting the next scanning round
60s - core thread idle time
I don't think it's necessary to expose these configs to users, but I'm open to different ideas.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2357873549
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path, SafeModeAction}
import org.apache.hadoop.hdfs.DistributedFileSystem
import org.apache.hadoop.security.AccessControlException
+import org.apache.hadoop.util.BlockingThreadPoolExecutorService
Review Comment:
this class is marked with `@Private`, but the API has been stable since 2016, so it should be low risk to use directly.
--
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-53631][CORE][SHS] Optimize memory and perf on SHS bootstrap [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #52382:
URL: https://github.com/apache/spark/pull/52382#discussion_r2365641606
##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -34,6 +34,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path, SafeModeAction}
import org.apache.hadoop.hdfs.DistributedFileSystem
import org.apache.hadoop.security.AccessControlException
+import org.apache.hadoop.util.BlockingThreadPoolExecutorService
Review Comment:
@dongjoon-hyun @peter-toth The Hadoop code comes from [Apache S4](https://github.com/apache/incubator-retired-s4/blob/0.6.0-Final/subprojects/s4-comm/src/main/java/org/apache/s4/comm/staging/BlockingThreadPoolExecutorService.java), I wrote a simple "BlockingThreadPoolExecutorService" based on it, so we don't have to worry about using Hadoop private API.
--
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