Repository navigation
Conversation
|
QA tests have started for PR 1626. This patch merges cleanly. |
|
QA results for PR 1626: |
Contributor
|
LGTM. Going to merge it. |
xiliu82
pushed a commit
to xiliu82/spark
that referenced
this pull request
Sep 4, 2014
Author: Josh Rosen <joshrosen@apache.org> Closes apache#1626 from JoshRosen/SPARK-2305 and squashes the following commits: 03fb283 [Josh Rosen] Update Py4J to version 0.8.2.1.
sunchao
added a commit
to sunchao/spark
that referenced
this pull request
Jun 2, 2023
MaxGekk
added a commit
to MaxGekk/spark
that referenced
this pull request
Nov 23, 2026
…apache#1626) <!-- title: [VARKA-611] Add a magnitude pre-check for the checked BIGINT multiply --> ### What changes were proposed in this pull request? An ANSI or TRY `BIGINT` multiply declines when the bounds of its operands do not rule out overflow. It then runs on the row engine. This PR adds a pre-check in double lanes, behind an option that is off by default, so we can measure it against the decline on each host. - New IR node `GuardedProduct(left, right)`. A batch declines (status `INT_OVERFLOW`) when a live lane has `|(double) a * (double) b| >= 2^62`. The row engine then raises or returns null on the rows that overflow. - The test is safe: no overflowing row passes. - New emit option `checkedLongMultiply`: `BOUND_ONLY` (default, today's decline), `MAGNITUDE`, `BY_HOST`. - The fuzzer draws the node. The benchmark has a third arm and one new section. <details> <summary>Measured baseline, the node, the option and the other changes</summary> Today, an ANSI or TRY `BIGINT` multiply declines when the bounds of its operands do not rule out overflow (`l * m` over two columns, `try_multiply(l, m)`). It runs on the row engine. Its wrapping twin fuses whole. On the EPYC runner at 256 bits, the checked products tie the row path at 1.0X. In LEGACY, `l * 3` runs 6.6X and `l * m` runs 8.0X (`sql/core/benchmarks/VarkaBigintArithmeticBaselineBenchmark-jdk25-runner-epyc7763-results.txt`). This PR adds the second of the three forms that `VARKA-104.md` 3.3 lists: a pre-check in double lanes. It is an option, off by default, so we can measure it against the decline on each host. - New IR node `GuardedProduct(left, right)` on the long lane. Its value is the wrapping product `a * b`. A batch declines (status `INT_OVERFLOW`) when a live lane has `|(double) a * (double) b| >= 2^62`. The row engine then raises an error under ANSI, or returns null under TRY, on the rows that overflow. - The kernel converts both operands to double (one `convertShape` at emit level 3, the exact `XOR_SPLIT` form below it), multiplies, clears the sign bit, and compares the bits as longs with the bits of `2^62`. - The test is safe: a product that overflows a long is at least `2^63`, far past the bound plus the rounding error. So no overflowing row passes. A batch that declines but held no overflow is only answered by the row engine. - The reference evaluator runs the same double test in Java, so the reference and the kernel decline the same batches. - The node is not a mode of `IntArith`. An `IntArith(MUL, FAIL)` lowered this way would decline batches that its reference (`Math.multiplyExact`) answers. - New emit option `checkedLongMultiply` (reason `MACHINE`): `BOUND_ONLY` (default, today's decline), `MAGNITUDE`, `BY_HOST`. `MAGNITUDE` builds a `GuardedProduct` in a projection where `cannotOverflow` fails, at an emit level that lowers the conversion (`DeclineSink.guardsLongProducts`). `BY_HOST` does this on x86 at levels 2 and 3 only, and keeps the decline elsewhere (Arm included, where it is not measured). A filter condition and the unnamed default level keep the decline. The node is refused at the unnamed level with the reason `CONVERSION`. - Every exhaustive switch over the IR knows the new node. - The fuzzer draws the node on its own seed (`GUARDED_PRODUCT_FUZZ_SEED`) at levels 2 and 3 in turn. It holds the status to `VarkaGuardSpecs` and an answered batch to the reference. - `VarkaBigintArithmeticBaselineBenchmark` has a third arm, `varka on, B (checkedLongMultiply=MAGNITUDE)`, and one new section that prices the decline (`l * m, ANSI, products near 2^62`). </details> ### Why are the changes needed? Whether the pre-check beats the decline depends on the host. The prediction, recorded before the run, is that it loses at 128 bits, and may win at AVX-512 and on the AVX2 of the EPYC at 256 bits. We can choose a default for each host only from the readings of the runners. <details> <summary>More on the reason</summary> Whether the pre-check beats the decline depends on the host. The prediction, recorded before the run, is that it loses at 128 bits, and may win at AVX-512 and on the AVX2 of the EPYC at 256 bits (`VARKA-611.md` 6.1). We can choose a default for each host only from the readings of the runners. For the readings, the form must exist behind an option that changes nothing by default. I built `BY_HOST` now so that one commit can name the winning levels later. It is not the default. </details> ### Does this PR introduce _any_ user-facing change? No. The option is `BOUND_ONLY` by default, so every session compiles and answers as before. No session configuration sets it. ### How was this patch tested? On the laptop (AVX-512, 256-bit datapath), on 22 November 2026, at the head after the merge of `origin/master`: - Regeneration moved nothing. Push check, Error Prone, `lint-scala`, the catalyst suites and the sql queries suite (2 tests) passed. The queries suite first failed on its own expectation, not the node. I fixed the suite. - After a later merge of `origin/master`, I ran only the push check again: 190 ok, 0 failed, 5 cancelled. I did not repeat the other runs. - Not run: the benchmark on any host (the runners must read it), a CI Build, and the option matrix. - Option matrix run 45158540579 failed `VarkaBigIntConformanceSuite` under `useAVX=2` with `checkedLongMultiply=MAGNITUDE` and `BY_HOST`: the registers describe the defaults, so the fused multiply read as drift. The check now asks the options, as the compiler does, and holds each batch to the pre-check's verdict; `dev/varka_matrix.sh` passes both configurations and the defaults (23 November 2026). <details> <summary>Full test record and the queries-suite failure</summary> On the laptop (AVX-512, 256-bit datapath), one sbt at a time, `SPARK_LOCAL_IP=127.0.0.1`, on 22 November 2026, at the head of the branch after the merge of `origin/master`: - `dev/varka_regen_generated.sh --all`: nothing moved. - `python3 dev/varka_push_check.py` passed. Its matrix ran 13 suites with the defaults. - `dev/varka_errorprone.sh` and `dev/lint-scala` passed. - `build/sbt 'catalyst/testOnly *VarkaEmitCostSuite *VarkaEmitterBudgetSuite *VarkaEmitterLongLaneSuite *VarkaIrFuzzSuite *VarkaLaneTypeSuite *VarkaRangeAnalysisSuite *VarkaReproductionSuite *VarkaWithChildrenSuite'` passed. The fuzz suite runs the guarded draw at levels 2 and 3. - `build/sbt 'sql/testOnly *VarkaBigintArithmeticBaselineQueriesSuite'` passed (2 tests). After that, `origin/master` moved to `0378c696c3a` (apache#1618, apache#1620: a fix of the conjunct order rule, and a results-only commit). I merged it without conflict. I ran only the push check again on that merge. It passed (13 suites, the defaults, 190 ok, 0 failed, 5 cancelled). I did not repeat the other runs on it. The queries suite first failed on the B arm of the benchmark. `l * 3, ANSI, no nulls` planned `NONE`, and the suite expected `WHOLE`. The cause was the expectation of the suite, not the node. The shared test sessions pin `spark.sql.codegen.varka.emit.useAVX=-1`, the unnamed level. There, B declines by design, because the kernel plan refuses the long-to-double conversion. The sessions of the benchmark use the named level of the host. The suite now checks both. Under `MAGNITUDE` at the unnamed level, a section keeps its class (B declines like A). At level 2, the B arm plans `WHOLE` (`NONE` where the host declines two-lane checks). Not run: the benchmark on any host (the runners must read it), a CI Build, and the option matrix. </details> ### Review `/code-review high`: 0 important findings. Five nits are left. Two are open limits: the benchmark results files are stale until the runner readings land, and the `BY_HOST` level set is provisional. <details> <summary>Earlier review and the nit list</summary> `/code-review high` ran on 22 November 2026 on `varka-611-guarded-product-r` in `/home/max/proj/varka-611w` (merge base `96f7ff5402b`). It found no important defect. An earlier `/code-review medium` found two defects. I fixed both: - A misplaced brace in the constructor of `VarkaEmitOptions`. - A `longValueExact` in the guard spec over operands whose wrapping value can leave the long range. Five nits are left as they are: - The `PLAN.md` status cell of row 611 still listed the decline section as left. Fixed on 23 November 2026. - The results files of the benchmark are not regenerated for the two new columns and the third arm. The readings of the runners are owed, and the file is stale until they land. - At the unnamed level, the refusal of `GuardedProduct` in the kernel plan only guards hand-built trees, because the compiler never builds one there. - The level set of `BY_HOST` is provisional until the readings narrow it. - The guarded fuzz draw runs level-3 kernels on AVX2 hosts through the Java fallback of the Vector API. This is correct but slow. </details> ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Sonnet 5.5, Claude Opus 5.5)
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)
MaxGekk
added a commit
to MaxGekk/spark
that referenced
this pull request
Nov 24, 2026
…wo lanes (apache#1663) <!-- title: [VARKA-612] Decline the day-time interval checks measured slower at two lanes --> ### What changes were proposed in this pull request? At 128 bits an x86 host has two 64-bit lanes, and C2 lowers no 64-bit mask there, so a long-lane check's compare runs as the Vector API's Java loop. The day-time interval baseline read 0.5x to 1.0x at 128 bits, against 3.9x to 4.4x at 256. Master already declines a checked `BIGINT` operation there. - On that host the compiler now also declines the checked day-time interval arithmetic measured slower: `dt + dt2`, `dt - dt2`, `abs(dt)` and `dt * k`, with `TWO_LANE_CHECK_REASON` in EXPLAIN (`VarkaIntervalCompiler.twoLaneMeasured`). - Only the form's own check counts. A form whose check the range lattice removed, or whose only check sits in an operand, keeps fusing. - The day-time baseline lists its three checked sections as `NONE` under the refusal, and its suite checks both settings. - `VarkaTwoLaneDefault128Suite` enables `TIME` and checks the day-time arms decline while `TIME` and `TIMESTAMP_NTZ` checks fuse beside them. - A two-lane census of the coverage table's value rows, `results/VARKA-612-refused.txt` (13 of 476), which `VarkaCoverageSuite` holds to what it renders. <details> <summary>What still fuses unmeasured, and design details</summary> These long-lane checks keep fusing at two lanes, never measured there: `-dt`, `TIME`'s and `TIMESTAMP_NTZ`'s (`t + dts`, `ntz + dt`, `ntz - ntz2`, `timestampadd`), the ANSI and try narrowing casts of a `BIGINT` (`CAST(l AS INT)`), `d - d2`, `CAST(d AS TIMESTAMP_NTZ)` and `CAST(dt AS BIGINT)`. Their 128-bit measurement is owed as a follow-up (`VARKA-612.md` 9.4): no section times ANSI `CAST(l AS INT)`, `try_cast(l AS INT)`, `timestampadd(MONTH, <bigint>, ntz)`, `CAST(d AS TIMESTAMP_NTZ)` or `d - d2` yet, so new sections come first, then two runs at `-XX:MaxVectorSize=16` on an EPYC 7763, compared by minimums. A family slower there joins `twoLaneMeasured` in its own change. The kernel plan refuses no check; `VarkaKernelPlan.holdsLongLaneCheck` is the walk the tests ask. `VARKA-612-refused.txt` is rewritten by every coverage regeneration. `dev/varka_generated_merge.py` does not know the file, so a later branch that adds coverage rows (337a3, 609) must regenerate it, as `pre-pr.sh`'s full regeneration does. </details> ### Why are the changes needed? The checked day-time arms ran slower than the row path at 128 bits, so fusing them there costs time. The refusal sends them to the row path, as master does for a checked `BIGINT` operation. ### Does this PR introduce _any_ user-facing change? No new setting. On x86 at 128 bits, the checked day-time interval arithmetic runs on the row path, with the reason in EXPLAIN. Answers are unchanged. ### How was this patch tested? On the laptop, after the narrowing and its review fixes: `catalyst/testOnly *VarkaTwoLaneConditionSuite *VarkaCoverageSuite` passed (26, 1 cancelled), with the census file regenerated unchanged, and `*VarkaExpressionCompilerSuite -- -z "two-lane"` passed (3). Before the last fix: `sql/testOnly *VarkaTwoLaneDefault128Suite` (5) and the day-time, integral-cast and three `TIMESTAMP_NTZ` baseline queries suites passed (12). The full local gate (`~/varka-ops/pre-pr.sh`) passed on `abf59d39901`. It merged master at `8e631d8ed41`, and its regeneration commit moved `width_audit.json`, `docs/sql-varka.md`, `casts_suites.tsv` and one line of `VARKA-612-refused.txt`. Extra-gate (lints, Error Prone, invariant and proof suites) passed, and so did the push check, at 450 counted lines. It passed again on `200cda31dfb`, the merge of master at `c4b0475d86e`, which brings apache#1669's regenerated `casts_suites.tsv` and apache#1626: that merge hand-resolved `DeclineSink`, `VarkaNodeCompiler` (master's `guardsProduct` kept, its copy of `TWO_LANE_CHECK_REASON` dropped for this branch's `VarkaKernelPlan` one) and `VarkaEmitterLongLaneSuite`'s new two-lane assertion, and a `/code-review high` of the resolution found no bug in it; the regeneration moved nothing, and the arm sweep over the changed catalyst and sql suites passed at the defaults, `useAVX=2` and `useAVX=3`. The arm sweep ran every configuration (59 and the defaults) without a failure. `VarkaCoverageSuite` and `VarkaExpressionCompilerSuite`: 11,174 passed, 340 cancelled. `VarkaDayTimeIntervalBaselineQueriesSuite` and `VarkaTwoLaneDefault128Suite`: 361 passed, 59 cancelled. CI is held at the owner's request. This PR is opened so its owed benchmarks can run on the runners. The CI Build and the option matrix run later. <details> <summary>What is owed</summary> The 128-bit measurement of the unmeasured families, and a 128-bit rerun of `VarkaDayTimeIntervalBaselineBenchmark`, whose committed file still says the three checked sections fuse (`VARKA-612.md` 9.4, the owner's dispatch). A CI Build and the option matrix. </details> ### Review The first `/code-review high` found that the 128-bit suite's test would be left to Spark by row 613's rule, and that the census file was not committed; both are fixed. On the owner's decision the refusal was then narrowed from a tree walk over every long-lane check to the measured family. The re-review of that found two important issues: the stale width audit, which the regeneration answers, and an operand's check declining a measured form, now fixed. The review covers `120f563f38e`. After it come only the gate's master merge and its regeneration commit. <details> <summary>The nits left</summary> - `VARKA-612-refused.txt` is unknown to the generated-file merge driver (above). - `notACheck` tests only int-driven plans. </details> ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5)
MaxGekk
added a commit
to MaxGekk/spark
that referenced
this pull request
Nov 25, 2026
…r green (apache#1744) ### What changes were proposed in this pull request? This pull request splits one test of `VarkaEmittedBytesSuite` into seven. It changes test code only. The suite's pin test checks that the emitter still produces the bytes that `sql/varka/emitted_bytes.json` records for every shape. Until now one test computed the whole file: the shapes at the default options at both vector widths, and a digest of every shape for each option arm. - The first new test computes the shapes at the defaults at both widths. - Six more tests compute one share each of the option arms' digests. - Each test computes its share, takes the rest from the committed file, and compares the whole file byte for byte. So the check is the same as before. - A regeneration still computes and writes the file in one test. - Each test reports its time for each group of shapes. ### Why are the changes needed? Each Varka test has a watchdog of 600 seconds. The pin test is near that cap on the slowest class of CI runner, the AMD EPYC 7763. - On 25 November 2026 it took 579.4 seconds on an EPYC 7763 in master's run 45678631423. On faster runners it took 328 seconds in master's run 45667844008 and 295 seconds in apache#1711's Build, on an Intel Xeon 6975P-C. - On 23 November 2026 it took 511 to 551 seconds on EPYC 7763 runners. Then apache#1626 pushed it past the cap, master failed 3 of 3 attempts, and apache#1626 was reverted (`sql/varka/AGENTS.md` records this). - The test's time grows with each coverage row. Two open pull requests add rows: apache#1710 adds 7 and apache#1711 adds 36. With the present 21 seconds of margin, either can turn master red on a slow runner. After the split, no test of the file computes more than one sixth of the option arms' digests. ### Does this PR introduce _any_ user-facing change? No. Test code only. ### How was this patch tested? - `VarkaEmittedBytesSuite` on the laptop (an AMD Ryzen AI 9 HX PRO 370, JDK 25), on this branch merged with master at `2fea7020a8f`: 14 tests pass, and the 2 opt-in audits do not run. The defaults' test takes 8.5 seconds and each of the six parts takes 16.3 to 17.8 seconds. - The same suite on 4 cores of the laptop, on 23 November 2026, as a CI runner has 4 cores: the defaults' test took 11.1 seconds and each part took 26.4 to 29.2 seconds. - The check is unchanged, so `sql/varka/emitted_bytes.json` is not regenerated. - Size: 286 counted lines, in one test file. Known limits, not changed here: - A regeneration computes the whole file in one test under the same watchdog. It takes about one minute on the laptop. - The test "an arm the option matrix runs in another's place emits that arm's bytes" is now the longest of the suite: 35.6 seconds on the laptop. It took 83.2 seconds on a CI runner in apache#1711's Build. **Review.** One `/code-review high` round on 23 November 2026 found 7 points, 1 of them important. The important one is fixed: the list of moved shapes threw a `NullPointerException` when the committed lanes that a test copies had no sequence. Three nits are fixed: the name of the defaults' test, a section header that split unrelated tests, and history in a comment. Three points are trade-offs that stay: the two limits above, and the setup that each part repeats. The only commit since that review is a merge of master, with no conflict. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5, Claude Fable 5.2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.