Repository navigation
[SPARK-3411] Improve load-balancing of concurrently-submitted drivers across workers - #1106
WangTaoTheTonic wants to merge 7 commits into
Conversation
|
Can one of the admins verify this patch? |
|
did you see any performance impact on the current strategy, "randomization at the start of every schedule point" is used not only at Master but also TaskSchedulerImpl... until so far, it works fine...... |
|
You mean the increased shuffles may lead to a bad performance? |
|
yes, potentially... and considering the long-term running of the cluster, eventually, the load is well balanced with the current strategy.....i.e. this commit only contributes to the case that the user submits a lot of drivers in a single batch and then waits for the result... |
|
Another situation is that the works lists changes frequently, which will make drivers relaunching a lot. Even when resources in all workers is not enough at same time, the drivers array could become larger as users keep submitting. |
|
I'm not sure about efficiency of changing to another mode for the extreme case that some worker (which is exactly the one running a lot of drivers) joins and leaves constantly.... for the second case, when the resources in all workers is not enough at same time, the driver cannot be scheduled..... |
|
Make it short, the commit will better balance the load strategy when there comes a lot of drivers, while not result in bad performance when drivers is few as the randomization frequency depends on drivers number. |
|
@WangTaoTheTonic Can you up merge this with master? Also could you file a JIRA associated with this PR? |
There was a problem hiding this comment.
This creates multiple copies of all the workers and could be slow for large clusters. Maybe it's a better idea to keep track of a list of alive workers instead
e3d87e2 to
e243c5f
Compare
|
The PR is: https://issues.apache.org/jira/browse/SPARK-3411. |
|
Can you give this PR a more descriptive title? "Optimize the schedule procedure in Master" sounds like it could describe many different changes, so it's kind of hard to figure out what this PR might do by reading the current title. I'd go with something like "[SPARK-3411] Improve load-balancing of concurrently-submitted drivers across workers." |
|
I agree that this seems like a bit of a rare corner-case. |
|
@WangTaoTheTonic I looked at this more and I think it will actually be slower with the new changes. Before this patch we shuffle all the workers only once, but here we shuffle it for each waiting driver. If we have thousands of workers, shuffling can become fairly expensive. As for the original problem you set out to solve, it seems to me that the existing code is already doing the randomization correctly. This is because we draw the first worker from a list of shuffled workers, so it will already be random by the time we draw from it. |
|
If the problem is all of the drivers landing on the same randomly-chosen worker, I suppose you could treat the randomized list as a circular buffer and go through it in a round-robin order when picking which worker to launch the next driver on. |
|
Oh I see. Wouldn't it be sufficient to just pop the head of |
|
Yeah, I suppose so, but there was one corner-case that I was concerned about (that is addressed by treating it as a circular buffer): Let's say we have a scenario where we are trying to schedule three drivers but there are only two workers that they can run on, and let's also say that there's initially enough capacity to run all three drivers. In that case, I think we would pop the head of The circular buffer brings its own problems, though: let's say that there are no valid locations where we can schedule the driver. In this case, we should stop looping through the buffer so that we don't go into an infinite loop. |
|
Hm, it looks like (semi-pseudocode) |
|
To @JoshRosen , the pr title is already modified, so is the jira. |
|
QA tests have started for PR 1106 at commit
|
|
QA tests have finished for PR 1106 at commit
|
|
QA tests have started for PR 1106 at commit
|
|
QA tests have finished for PR 1106 at commit
|
9a7bf94 to
2ca3091
Compare
|
QA tests have finished for PR 1106 at commit
|
There was a problem hiding this comment.
Somewhat minor, but why don't we just declare val startPos = curPos after we increment it? Then we don't need the -1 here
|
@WangTaoTheTonic This mostly looks good. I left a few more minor comments. Anything else to add @markhamstra and @JoshRosen? |
There was a problem hiding this comment.
This could be just:
for (driver <- waitingDrivers.toList)|
QA tests have started for PR 1106 at commit
|
|
QA tests have finished for PR 1106 at commit
|
76346bc to
d1a928b
Compare
|
QA tests have started for PR 1106 at commit
|
|
QA tests have finished for PR 1106 at commit
|
|
Thanks @WangTaoTheTonic I'm merging this |
I think, this issue is caused by #1106 Author: Kousuke Saruta <sarutak@oss.nttdata.co.jp> Closes #2436 from sarutak/SPARK-3571 and squashes the following commits: 7a4deea [Kousuke Saruta] Modified Master.scala to use numWorkersVisited and numWorkersAlive instead of stopPos 4e51e35 [Kousuke Saruta] Modified Master to prevent from 0 divide 4817ecd [Kousuke Saruta] Brushed up previous change 71e84b6 [Kousuke Saruta] Modified Master to enable schedule normally
## What changes were proposed in this pull request? This patch contains the functionality to balance the load of the cluster-mode drivers among workers This patch restores the changes in #1106 which was erased due to the merging of #731 ## How was this patch tested? test with existing test cases Author: CodingCat <zhunansjtu@gmail.com> Closes #11702 from CodingCat/SPARK-13803. (cherry picked from commit bd5365b) Signed-off-by: Sean Owen <sowen@cloudera.com>
## What changes were proposed in this pull request? This patch contains the functionality to balance the load of the cluster-mode drivers among workers This patch restores the changes in #1106 which was erased due to the merging of #731 ## How was this patch tested? test with existing test cases Author: CodingCat <zhunansjtu@gmail.com> Closes #11702 from CodingCat/SPARK-13803.
## What changes were proposed in this pull request? This patch contains the functionality to balance the load of the cluster-mode drivers among workers This patch restores the changes in #1106 which was erased due to the merging of #731 ## How was this patch tested? test with existing test cases Author: CodingCat <zhunansjtu@gmail.com> Closes #11702 from CodingCat/SPARK-13803. (cherry picked from commit bd5365b) Signed-off-by: Sean Owen <sowen@cloudera.com>
## What changes were proposed in this pull request? This patch contains the functionality to balance the load of the cluster-mode drivers among workers This patch restores the changes in #1106 which was erased due to the merging of #731 ## How was this patch tested? test with existing test cases Author: CodingCat <zhunansjtu@gmail.com> Closes #11702 from CodingCat/SPARK-13803. (cherry picked from commit bd5365b) Signed-off-by: Sean Owen <sowen@cloudera.com>
## What changes were proposed in this pull request? This patch contains the functionality to balance the load of the cluster-mode drivers among workers This patch restores the changes in apache#1106 which was erased due to the merging of apache#731 ## How was this patch tested? test with existing test cases Author: CodingCat <zhunansjtu@gmail.com> Closes apache#11702 from CodingCat/SPARK-13803.
…Base (apache#1106) Co-authored-by: Egor Krivokon <>
…ssion (apache#1107) ### What changes were proposed in this pull request? The date, interval and integer kernels' answer checks now run without a Spark session, through the expression harness that the coverage and TIME suites already use. `VarkaDifferentialSuite` keeps the 27 tests that need a session. **This PR sits on apache#1106, which sits on apache#1105.** Its own commits are the last two. - **`VarkaDifferentialHarnessSuite`** holds 68 of the old suite's 94 tests, under their old names, over the same tables. The tables are now SQL `VALUES` with the old nullability: where the old table declared a column nullable that holds no null, an all-null row goes into the `VALUES` and is filtered out again. Without it, Spark would read the column as non-nullable, and the optimizer would rewrite some queries; `coalesce(d, d2)`, for example, would become `d`. - **`VarkaHarnessCases`** now lets one test run its queries in parts, each with its own table, ANSI mode and emit options, as the old tests set them between queries. Each query states what the old test asserted of the plan and the node's metrics: | Expectation | Old assertion | |---|---| | something fused, and a kernel answered a batch | `checkDifferential(..., expectFused = true)` | | something fused | `assertFused` alone | | fused whole and served every batch | `numFallbackBatchesDeclined === 0` beside a kernel run | | fused whole, and a kernel declined a batch with its own status | `numFallbackBatchesDeclined > 0` | | nothing fused | `expectFused = false` | Where the old test read verbose `EXPLAIN`, the harness checks the same lines from `VarkaFusionReport`: `"far: residual (day range ["`, `"kernel 2 of 2"` and the others. - **Two changes to how the harness runs a query:** - *Filters:* the filter evaluator is handed only the conjuncts the compiler fuses. That is what `VarkaColumnarRule` hands the Varka node, leaving the rest to a row filter above it. The evaluator compiles only a condition that fuses whole, so without this a filter with one residual conjunct fell back on every batch. - *The row consumer:* it now compares only the outputs `projectFused` returns. Projections with residual or forwarded entries therefore run through the row node's path too. - **`VarkaDifferentialSuite`** keeps what needs a session: - the plan around the Varka nodes: a narrowing projection absorbed, a residual conjunct's row filter and the order Spark evaluates conjuncts in, a projection stacked on a filter's compacted batch, the common-expression hoist; - the fallback hooks and the metrics they move; - AQE, aggregation, the cache's batches, tasks sharing a kernel class, a non-Arrow source, the SQL UI's residual count, Metaspace; - the `guardDayProducers=false` test, which asserts only the metric, never the wrong values that configuration produces; the harness compares every answer; - the `ILLEGAL_DAY_OF_WEEK` error a user sees. No coverage row raises that condition, so no other session test shows it. - **`VarkaSharedSessions`** drops the seven fixtures no suite reads any more. - **`VarkaHarnessParitySuite`** plans every hand-written query of both harness suites in a session, under its part's ANSI mode, and requires each expression to equal the harness's. - **`skips.tsv`:** - 11 lines follow their tests to the new suite. - The `arrowBatchSize=1` line for "null-as-false, and the boundary selectivities" is removed. Its reason was the in-memory scan's statistics pruning one-row batches, and the harness has no scan, so the test now passes there. - **Docs:** `ADDING_AN_EXPRESSION.md` and `docs/sql-varka.md` now point to the harness suite. ### Why are the changes needed? The suite spent its time on session work. It ran each query through two sessions, sorted the results, and ran the query a second time for the warm cache. It took 66 s at the defaults on the laptop, and 3.66 h of the option matrix's run 40658422887. The checks need only the expressions and the batches. | Configuration | Before (old suite) | After (harness suite + session suite) | |---|---|---| | defaults | 66 s | 4.1 s + 36.7 s | | `arrowBatchSize=1` | 70 s | 4.6 s + 36.4 s | Results, with each of the 94 old tests mapped to where its check now lives: `sql/varka/plans/m8/results/VARKA-509-step3b-local.txt`. ### Does this PR introduce _any_ user-facing change? No. Tests only. ### How was this patch tested? - All 1,211 tests of the harness and session suites this work touches pass at the defaults, in one JVM. That includes the coverage suites and the 68 new tests. - I ran the six configurations that have skip lines for these tests locally: `checkIntOverflow=false`, `guardDayProducers=false`, `guardUnderArm=false`, `severalKernels=false`, `arrowBatchSize=1` and `validityByWidth=false`. Each test cancels where its line says, and nothing else fails. The CI matrix covers the other configurations. - `build/sbt 'sql/testOnly *VarkaDifferentialHarnessSuite'` runs the 68 tests, as `ADDING_AN_EXPRESSION.md` now says. - The linters pass. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5.5)
If the waiting driver array is too big, the drivers in it will be dispatched to the first worker we get(if it has enough resources), with or without the Randomization.
We should do randomization every time we dispatch a driver, in order to better balance drivers.