Skip to content

[SPARK-1021] Defer the data-driven computation of partition bounds in so... - #1689

Closed
erikerlandson wants to merge 7 commits into
apache:masterfrom
erikerlandson:spark-1021-pr
Closed

erikerlandson wants to merge 7 commits into
apache:masterfrom
erikerlandson:spark-1021-pr

Conversation

@erikerlandson

Copy link
Copy Markdown
Contributor

...rtByKey() until evaluation.

@AmplabJenkins

Copy link
Copy Markdown

Can one of the admins verify this patch?

@JoshRosen

Copy link
Copy Markdown
Contributor

Jenkins, this is ok to test.

@SparkQA

SparkQA commented Jul 31, 2014

Copy link
Copy Markdown

QA tests have started for PR 1689. This patch merges cleanly.
View progress: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/17611/consoleFull

@SparkQA

SparkQA commented Jul 31, 2014

Copy link
Copy Markdown

QA results for PR 1689:
- This patch PASSES unit tests.
- This patch merges cleanly
- This patch adds no public classes

For more information see test ouptut:
https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/17611/consoleFull

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we perhaps make this thread safe?

@SparkQA

SparkQA commented Aug 7, 2014

Copy link
Copy Markdown

QA tests have started for PR 1689. This patch merges cleanly.
View progress: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/18089/consoleFull

@SparkQA

SparkQA commented Aug 7, 2014

Copy link
Copy Markdown

QA results for PR 1689:
- This patch PASSES unit tests.
- This patch merges cleanly
- This patch adds no public classes

For more information see test ouptut:
https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/18089/consoleFull

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not want to deserialize valRB if it is not null? Are you worried rangeBounds might be called while the deserialization is happening?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also was assuming readObject might be called in multiple threads. Can that happen?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not possible

@erikerlandson

Copy link
Copy Markdown
Contributor Author

Latest push updates RangePartition sampling job to be async, and updates the async action functions so that they will properly enclose the sampling job induced by calling 'partitions'.

@SparkQA

SparkQA commented Aug 15, 2014

Copy link
Copy Markdown

QA tests have started for PR 1689 at commit 09f0637.

  • This patch merges cleanly.

@markhamstra

Copy link
Copy Markdown
Contributor

Excellent! I'll try to find some time to review this soon.

@SparkQA

SparkQA commented Aug 15, 2014

Copy link
Copy Markdown

QA tests have finished for PR 1689 at commit 09f0637.

  • This patch passes unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

SparkQA commented Aug 16, 2014

Copy link
Copy Markdown

QA tests have started for PR 1689 at commit f3448e4.

  • This patch merges cleanly.

@SparkQA

SparkQA commented Aug 16, 2014

Copy link
Copy Markdown

QA tests have finished for PR 1689 at commit f3448e4.

  • This patch passes unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

SparkQA commented Sep 5, 2014

Copy link
Copy Markdown

Can one of the admins verify this patch?

@rxin

rxin commented Sep 12, 2014

Copy link
Copy Markdown
Contributor

Jenkins, test this please.

@SparkQA

SparkQA commented Sep 12, 2014

Copy link
Copy Markdown

QA tests have started for PR 1689 at commit 50b6da6.

  • This patch merges cleanly.

@rxin

rxin commented Sep 12, 2014

Copy link
Copy Markdown
Contributor

@erikerlandson thanks for looking at this.

A few questions:

  1. After this pull request, does anything still use SimpleFutureAction?
  2. If I understand this correctly, this could potentially block the single-threaded scheduler from doing anything else while waiting for the rangeBounds to be computed. Any comment on this?
  3. This is not always lazy still right? See a test case
c.parallelize(1 to 1000).map(x => (x, x)).sortByKey().join(sc.parallelize(1 to 10).map(x=>(x,x)))

@SparkQA

SparkQA commented Sep 12, 2014

Copy link
Copy Markdown

QA tests have finished for PR 1689 at commit 50b6da6.

  • This patch passes unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@erikerlandson

Copy link
Copy Markdown
Contributor Author

Hi @rxin,

  1. SimpleFutureAction is still referred to in submitJob method, but that doesn't appear to be invoked anywhere. I was reluctant to get rid of it, as it's all experimental, and I could envision use cases for it.

  2. I see your point. I don't currently have any clever ideas to avoid that scenario when it happens.

  3. Very interesting -- so this scenario is triggered because defaultPartitioner starts examining input RDD partitioners, which sets off the job when it trips over the data driven partitioning computation from sortByKey.

My impression is that this whack-a-mole with non-laziness stems from a combination of (a) a data-dependent partitioner(s), with (b) methods that refer to input partitioners as part of the construction of new RDDs. It might be possible to thread some design changes around so that references to partitioning are consistently encapsulated in a Future. Functions such as defaultPartitioner would then also have to return a Future, etc. Or, even more generally, somehow encapsulate all RDD initialization in a Future, with the idea that these futures would finally unwind when some Action was invoked.

However it seems (imo) outside the scope of this particular Jira/PR. Maybe we could start another umbrella Jira to track possible solutions along these lines.

Another orthogonal thought -- you can short circuit all this by providing a partitioner instead of forcing it to be computed from data. That's not as sexy, or widely applicable, as some deeper fix to the problem, but users can do it now as a workaround when it's feasible.

@erikerlandson

Copy link
Copy Markdown
Contributor Author

Or, maybe just look into playing the same game with the cogrouped RDDs that I did with sortByKey. Don't get into invoking defaultPartitioner until somebody asks for the output RDD's partitioner, etc.

@rxin

rxin commented Sep 16, 2014

Copy link
Copy Markdown
Contributor

Yea I don't think we need to fully solve 3 here.

My main concern with these set of changes is 2, since a single badly behaved RDD can potentially block the (unfortunately single threaded) scheduler forever. Let me think about this a little bit and get back to you.

If you have an idea about how to fix that, feel free to suggest them.

@erikerlandson

Copy link
Copy Markdown
Contributor Author

So far the best idea I have for (2) is to set some kind of time-out on the evaluation. The bound computation uses subsampling that will (when all goes well) cap the computation at constant time(*). If the timeout triggers, some sub-optimal falback for partitioning might be used. Or just fail the entire evaluation.

(*) more accurately, constant number of samples. the time required could depend on various things.

@rxin

rxin commented Sep 27, 2014

Copy link
Copy Markdown
Contributor

Actually I looked at it again. I don't think it would block the scheduler because we compute partitions outside the scheduler thread. This approach looks good to me!

@rxin

rxin commented Sep 27, 2014

Copy link
Copy Markdown
Contributor

@erikerlandson i'm going to merge this first. Maybe we can do the cleanup later.

@asfgit asfgit closed this in 2d972fd Sep 27, 2014
@rxin

rxin commented Sep 27, 2014

Copy link
Copy Markdown
Contributor

BTW one thing that would be great to add is a test that makes sure we don't block the main dag scheduler thread. The reason I think we don't block is that we call rdd.partitions.length in submitJob:

  /**
   * Submit a job to the job scheduler and get a JobWaiter object back. The JobWaiter object
   * can be used to block until the the job finishes executing or can be used to cancel the job.
   */
  def submitJob[T, U](
      rdd: RDD[T],
      func: (TaskContext, Iterator[T]) => U,
      partitions: Seq[Int],
      callSite: CallSite,
      allowLocal: Boolean,
      resultHandler: (Int, U) => Unit,
      properties: Properties = null): JobWaiter[U] =
  {
    // Check to make sure we are not launching a task on a partition that does not exist.
    val maxPartitions = rdd.partitions.length

@markhamstra

Copy link
Copy Markdown
Contributor

Have either of you thought about how to coordinate this with Josh's work on SPARK-3626? #2482

@marmbrus

Copy link
Copy Markdown
Contributor

Since this PR was merged the correlationoptimizer14 test has been hanging. We might want to consider rolling back. You can reproduce the problem as follows: sbt -Dspark.hive.whitelist=correlationoptimizer14 hive/test

@rxin

rxin commented Sep 29, 2014

Copy link
Copy Markdown
Contributor

I reverted this commit. @erikerlandson mind taking a look at this problem?

@erikerlandson

Copy link
Copy Markdown
Contributor Author

@rxin @marmbrus I will check it out

@erikerlandson

Copy link
Copy Markdown
Contributor Author

@marmbrus, FWIW, the correlationoptimizer14 test appears to be working for me. I ran it using: env _RUN_SQL_TESTS=true _SQL_TESTS_ONLY=true ./dev/run-tests > ~/run-tests-1021.txt 2>&1

Not sure why, but runningsbt -Dspark.hive.whitelist=correlationoptimizer14 hive/test was not causing the test to run in my environment.

sunchao pushed a commit to sunchao/spark that referenced this pull request Jun 2, 2023
…apache#1689)

We’ve added checkAllStateStoreProviders for Dedisco project to allow checking all state stores which is a debugging feature.

One thing we recently discussed with Dedisco project is, the time spent on such check is not counted by reportTimeTaken which can be observed in stream progress later.
MaxGekk added a commit to MaxGekk/spark that referenced this pull request Nov 24, 2026
…ache#1689)

### What changes were proposed in this pull request?

This PR reverts apache#1626 (squash commit `c4b0475d86e`, row 611). That PR added the `GuardedProduct` node, the `checkedLongMultiply` emit option and three option arms in `sql/varka/emitted_bytes.json`. The tree equals master minus apache#1626: `git diff c4b0475^ HEAD -- . ':!sql/varka/plans'` shows only apache#1687's later `dev/` changes, which this PR keeps, and one README example fixed (below).

A second commit adds a dated note, `VARKA-611.md` 9.2, and a new newest state on `PLAN.md` row 611. The plan text apache#1626 added stays as the record of what was built. The note says the work is reverted at the owner's word and must be redesigned before it lands again, and it lists what the redesign owes:

- **Its pin guarded none of its code.** On `c4b0475d86e`, `emitted_bytes.json` has 27 option arms and 11 distinct digests. The three `checkedLongMultiply` arms emit the same bytes as `useAVX=2` on every pinned shape (14 arms share those digests). The redesign must pin a shape whose bytes the guarded product changes.
- **No new machine option with a non-default subject lands until the pin test is split or cached.** The split is branch `varka-emitted-bytes-budget`, not yet a pull request.
- **The default per host belongs to row 648** (fuse where faster, else decline), whose plan is not on master yet.
- **Keep the conformance fix.** `VarkaTypeConformance.guardsProduct` and the check that holds a batch's status to the guards' verdict are to come back with the redesign.

### Why are the changes needed?

Master is red. The pin test in `VarkaEmittedBytesSuite` ("sql/varka/emitted_bytes.json pins what the emitter produces for every shape") passes its 600 s cap on the AVX2 EPYC 7763 runners. Master run 45256702183 failed 3 of 3 attempts, all on 7763s. Before apache#1626 the test took 511 to 551 s on AVX2-only runners. apache#1626's three arms are each a full emission pass at both widths (option arms 24 to 27), which puts it at about 615 to 650 s. That figure is extrapolated, since the red runs stop at the cap. On the fast EPYC 9V45 the same test grew from 281-295 s to 334 s, which is why apache#1626's own master run passed.

Master must be green before the row 489 refactoring. This is a critical fix, which the hold on new PRs before row 489 allows.

### Does this PR introduce _any_ user-facing change?

No. The option was off by default (`BOUND_ONLY`, today's decline), and no session reached the other values.

### How was this patch tested?

`git revert` of `c4b0475d86e` applied with no conflicts. The local gate (`pre-pr.sh`: regeneration of the generated files, the arm sweep, the linters and the push check) passed on this branch. No `GuardedProduct`, `checkedLongMultiply`, `guardsProduct` or `guardsLongProducts` is left outside the plans: a worked example in `dev/varka_ops/README.md`, from apache#1687, named the option, and this PR switches it to `useAVX=2,narrowConversionForm=WINDOWED`. A `/code-review high` pass over the branch found six documentation nits, all fixed or recorded in the last commit. The full CI runs on this PR.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)
MaxGekk pushed a commit to MaxGekk/spark that referenced this pull request Nov 24, 2026
Master reverted apache#1626 (apache#1689). The conflicts were the guarded product's
remains from the earlier merge: VarkaNodeCompiler drops guardsProduct
and keeps the two-lane reason in VarkaKernelPlan only, DeclineSink's
constructor doc drops the guarded-product sentence, the long-lane suite
takes master's (the apache#1626 tests go), and PLAN.md takes master's row 611
and the branch's row 612.

Generated-by: Claude Code (Claude Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants