Skip to content

[SPARK-2104] Fix task serializing issues when sort with Java non serializable class - #1245

Closed
jerryshao wants to merge 3 commits into
apache:masterfrom
jerryshao:SPARK-2104
Closed

jerryshao wants to merge 3 commits into
apache:masterfrom
jerryshao:SPARK-2104

Conversation

@jerryshao

Copy link
Copy Markdown
Contributor

Details can be see in SPARK-2104. This work is based on Reynold's work, add some unit tests to validate the issue.

@rxin , would you please take a look at this PR, thanks a lot.

@AmplabJenkins

Copy link
Copy Markdown

Merged build triggered.

@AmplabJenkins

Copy link
Copy Markdown

Merged build started.

@AmplabJenkins

Copy link
Copy Markdown

Merged build finished. All automated tests passed.

@AmplabJenkins

Copy link
Copy Markdown

All automated tests passed.
Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/16205/

@rxin

rxin commented Jun 27, 2014

Copy link
Copy Markdown
Contributor

This looks good to me, but somebody else should review thsi too since I wrote half of the code here ...

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.

actually we probably want to make partitions just a constructor field, and have an internal variable private var numPartitions, so this class remains immutable from the user's point of view.

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.

make sure you replace references to partitions with numPartitions once you add the field

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.

Hi Reynold, thanks for your comments, will this field partitions be used in executor side, I think this field can be transient according to my knowledge, do I miss something?

@aarondav

Copy link
Copy Markdown
Contributor

This LGTM, besides @rxin's earlier comments.

@AmplabJenkins

Copy link
Copy Markdown

Merged build triggered.

@AmplabJenkins

Copy link
Copy Markdown

Merged build started.

@AmplabJenkins

Copy link
Copy Markdown

Merged build finished. All automated tests passed.

@AmplabJenkins

Copy link
Copy Markdown

All automated tests passed.
Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/16257/

@rxin

rxin commented Jun 30, 2014

Copy link
Copy Markdown
Contributor

Thanks. I'm merging this in master.

@asfgit asfgit closed this in 66135a3 Jun 30, 2014
xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
…alizable class

Details can be see in [SPARK-2104](https://issues.apache.org/jira/browse/SPARK-2104). This work is based on Reynold's work, add some unit tests to validate the issue.

@rxin , would you please take a look at this PR, thanks a lot.

Author: jerryshao <saisai.shao@intel.com>

Closes apache#1245 from jerryshao/SPARK-2104 and squashes the following commits:

c8ee362 [jerryshao] Make field partitions transient
2b41917 [jerryshao] Minor changes
47d763c [jerryshao] Fix task serializing issue when sort with Java non serializable class
mapr-devops pushed a commit to mapr/spark that referenced this pull request May 8, 2025
github-actions Bot pushed a commit to MaxGekk/spark that referenced this pull request Nov 1, 2026
…nners (apache#1245)

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

The EPYC 7763 runner results for the 24 sections that `VarkaDecimalBaselineBenchmark` gained for `DECIMAL` above precision 18, committed into the class's two results files.

The sections time `x IN (c1, c2, c3)`, `x <=> y`, `x IS NULL`, `-x < y` and `abs(x) < y` as filters and `x < y` as a projected value, over `DECIMAL(38, 10)` and `DECIMAL(20, 2)`, with no nulls and with one row in ten null. Their numbers come from `benchmark.yml` runs 41235267549 (256 bits) and 41237311797 (128 bits, `-XX:MaxVectorSize=16`), both on `2297f833e3b`, the head that added the sections:
- only the 24 new sections are spliced in, appended after the `TIME` sections where the class's section order puts them;
- every section already committed stays byte-identical. That includes the four `x < y` comparison sections at `DECIMAL(9, 2)` and `DECIMAL(18, 4)`, which now fuse on the varka on arm (both runs print that note for each of the four), so the committed file keeps their row-path numbers from before they fused;
- each provenance file gains a second block naming the new run, as the earlier `TIME` sections' splice did.

The plan texts that said these results were still to be spliced now say they are committed, citing the two runs.

### Why are the changes needed?

A later change will make these decimal forms run on vector lanes. Its speed-up is read as a diff against a committed row-path baseline, so the baseline must be in the tree before that change is measured.

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

No. This adds benchmark results and plan text only.

### How was this patch tested?

- `dev/varka_bench_diff.py --git f0c1ab1` on each results file shows 48 new rows (24 sections, two arms each) and no existing row moved.
- None of the 24 sections fuses, and in each the row-path and varka on arms' best times are within 0.9X to 1.1X of each other at both widths (from 0.95 to 1.10).
- The plan lint, the quote check and the pre-commit hook are clean.

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

Generated-by: Claude Code (Opus 5.5)
MaxGekk added a commit to MaxGekk/spark that referenced this pull request Nov 10, 2026
…e#1422)

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

New sections in Spark's row-path baseline for the decimal remainders by a column, `x % y` and `pmod(x, y)`, timed on the unchanged code before Varka gains a kernel for them.

`VarkaDecimalBaselineBenchmark` gains sixteen sections: `x % y` and `pmod(x, y)` as projected values at `DECIMAL(9, 2)`, `DECIMAL(18, 4)`, `DECIMAL(38, 10)` and `DECIMAL(20, 2)`, each with no nulls and with one row in ten null. They are appended after the existing 88 sections, so the committed results keep their places. Both operands of each section share a type, so the result has that type too and no operand is rescaled. Spark computes every one through `BigDecimal.remainder` per row.

No decimal remainder fuses at any precision today, so every new section is listed `Fusion.NONE`, and the benchmark's own fuse check confirms it before timing. `VarkaDecimalBaselineQueriesSuite` now expects 104 sections and checks the sixteen new result types. It also gains a test that generates the benchmark's full table at 2,000,000 rows, uncached, and counts the rows where a divisor column is zero: there must be none, because a zero divisor raises under ANSI and would stop the timed run.

The benchmark's fusion classes also follow the session's two-lane refusal (`spark.sql.codegen.varka.declineTwoLaneConditions`, apache#1262), as `VarkaFloatingCastBaselineBenchmark` already does: `sections(boolean declinesLongConditions)` lists the 30 filters over a `DECIMAL` of precision 9 or 18 (the equal-scale comparison, the five comparison shapes and the three arithmetic filters, at both densities) as `Fusion.NONE` when the session refuses a condition in a kernel driven at 64 bits, as an x86 host with two 64-bit lanes does by default, and `Fusion.WHOLE` otherwise. The projected `x < y` and the TIME producers stay `WHOLE`. Without it the 128-bit run (MaxGekk/spark run 42574807845) failed its fuse check: "DECIMAL(9, 2) comparison, no nulls is listed as WHOLE but plans as NONE". The queries suite's fuse test now checks both lists, setting the refusal off and then on in the Varka session.

`PLAN.md` marks row 577 started on this step, and `VARKA-577.md` 10.1 records it.

### Why are the changes needed?

The repository's rule for a change that speeds up a measured path is baseline first: the unchanged code's numbers are committed before the code that moves them, so the later change can be paired against them. Row 577 will fuse `%`, `mod`, `pmod` and `try_mod` over decimals, which no Varka kernel computes today, and these sections are the row path it will be measured against.

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

No. It adds benchmark sections, test checks and plan text only.

### How was this patch tested?

- `VarkaDecimalBaselineQueriesSuite` passes (10 tests) at the laptop's default width and at `-XX:MaxVectorSize=16`, including the fuse test, which holds the new sections at `Fusion.NONE` and checks every section's class with the two-lane refusal off and on, and the zero-divisor check at 2,000,000 rows.
- A scratch probe (not committed) planned every section on a benchmark-style session at the host's own refusal and compared each plan's class with the listed one: all 104 match at the laptop's default width (refusal off) and at `-XX:MaxVectorSize=16` (refusal on).
- `dev/lint-java` and scalastyle (catalyst and sql, main and test) pass over these two files, run on the stacked spike branch that contains this commit; `dev/varka_plan_lint.py --check --offline`, `dev/varka_quote_check.py` and the pre-commit hook pass on this branch.

The committed numbers come from these dispatches on this branch, not yet run. They time the class on an AMD EPYC 7763 runner at 256 and 128 bits:

```
gh workflow run benchmark.yml --repo MaxGekk/spark --ref varka-577-baseline -f class=VarkaDecimalBaselineBenchmark -f jdk=25 -f scala=2.13 -f num-splits=1 -f create-commit=false -f generate-tpcds=false -f runner=ubuntu-latest -f expected-cpu="AMD EPYC 7763"
gh workflow run benchmark.yml --repo MaxGekk/spark --ref varka-577-baseline -f class=VarkaDecimalBaselineBenchmark -f jdk=25 -f scala=2.13 -f num-splits=1 -f create-commit=false -f generate-tpcds=false -f runner=ubuntu-latest -f expected-cpu="AMD EPYC 7763" -f extra-java-options="-XX:MaxVectorSize=16"
```

Both runs write `VarkaDecimalBaselineBenchmark-jdk25-results.txt`, the name Spark's harness gives whatever the width, so they are not committed by the workflow (the second would overwrite the first, and neither is a committed name: the committed files carry `-runner-epyc7763`). Each run's file is taken from its artifact instead, and only the sixteen new sections are spliced into the committed file of its width, with the other 88 sections kept as committed:

```
gh run download <256-bit run id> --repo MaxGekk/spark --dir /tmp/b256 && tar -xf /tmp/b256/*/benchmark-results-25-2.13.tar -C /tmp/b256
gh run download <128-bit run id> --repo MaxGekk/spark --dir /tmp/b128 && tar -xf /tmp/b128/*/benchmark-results-25-2.13.tar -C /tmp/b128
dev/varka_bench_sections.py splice sql/core/benchmarks/VarkaDecimalBaselineBenchmark-jdk25-runner-epyc7763-results.txt /tmp/b256/sql/core/benchmarks/VarkaDecimalBaselineBenchmark-jdk25-results.txt --sections "$TITLES" --out sql/core/benchmarks/VarkaDecimalBaselineBenchmark-jdk25-runner-epyc7763-results.txt
dev/varka_bench_sections.py splice sql/core/benchmarks/VarkaDecimalBaselineBenchmark-jdk25-runner-epyc7763-128bit-results.txt /tmp/b128/sql/core/benchmarks/VarkaDecimalBaselineBenchmark-jdk25-results.txt --sections "$TITLES" --out sql/core/benchmarks/VarkaDecimalBaselineBenchmark-jdk25-runner-epyc7763-128bit-results.txt
```

with `TITLES` the sixteen titles, separated by `|` since the titles hold commas:

```
DECIMAL(9, 2) x % y as a value, no nulls|DECIMAL(9, 2) pmod(x, y) as a value, no nulls|DECIMAL(9, 2) x % y as a value, one row in ten null|DECIMAL(9, 2) pmod(x, y) as a value, one row in ten null|DECIMAL(18, 4) x % y as a value, no nulls|DECIMAL(18, 4) pmod(x, y) as a value, no nulls|DECIMAL(18, 4) x % y as a value, one row in ten null|DECIMAL(18, 4) pmod(x, y) as a value, one row in ten null|DECIMAL(38, 10) x % y as a value, no nulls|DECIMAL(38, 10) pmod(x, y) as a value, no nulls|DECIMAL(38, 10) x % y as a value, one row in ten null|DECIMAL(38, 10) pmod(x, y) as a value, one row in ten null|DECIMAL(20, 2) x % y as a value, no nulls|DECIMAL(20, 2) pmod(x, y) as a value, no nulls|DECIMAL(20, 2) x % y as a value, one row in ten null|DECIMAL(20, 2) pmod(x, y) as a value, one row in ten null
```

Each provenance sidecar gains a block naming its run, as apache#1245 did for the precision-38 sections, and the splice is a follow-up commit on this branch, checked with `dev/varka_bench_diff.py --git HEAD` on each file: 32 new rows (sixteen sections, two arms each) and no existing row moved.

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

Generated-by: Claude Code (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.

4 participants