Skip to content

[SPARK-1199][REPL][WIP] Changed wrappers to not use vals and thus avoid Path dependent types problem. - #1176

Closed
ScrapCodes wants to merge 2 commits into
apache:masterfrom
ScrapCodes:SPARK-1199/repl-case-class-fix
Closed

ScrapCodes wants to merge 2 commits into
apache:masterfrom
ScrapCodes:SPARK-1199/repl-case-class-fix

Conversation

@ScrapCodes

Copy link
Copy Markdown
Member

TODO: Write description. basically it fails for one particular scenario and I am enjoying tough time debugging it :)

@AmplabJenkins

Copy link
Copy Markdown

Merged build triggered.

@ScrapCodes ScrapCodes changed the title [Spark 1199][WIP] Changed wrappers to not use vals and thus avoid Path dependent types problem. [SPARK-1199][WIP] Changed wrappers to not use vals and thus avoid Path dependent types problem. Jun 22, 2014
@AmplabJenkins

Copy link
Copy Markdown

Merged build started.

@AmplabJenkins

Copy link
Copy Markdown

Merged build finished.

@AmplabJenkins

Copy link
Copy Markdown

Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/16013/

@ScrapCodes ScrapCodes changed the title [SPARK-1199][WIP] Changed wrappers to not use vals and thus avoid Path dependent types problem. [SPARK-1199][REPL][WIP] Changed wrappers to not use vals and thus avoid Path dependent types problem. Jun 23, 2014
@ScrapCodes

Copy link
Copy Markdown
Member Author

Closing this for now, will work on this later.

@ScrapCodes ScrapCodes closed this Jun 24, 2014
asfgit pushed a commit that referenced this pull request Jul 4, 2014
… defined classes.

This is an alternate solution to #1176.

Author: Prashant Sharma <prashant.s@imaginea.com>

Closes #1179 from ScrapCodes/SPARK-1199/repl-fix-second-approach and squashes the following commits:

820b34b [Prashant Sharma] Here we generate two kinds of import wrappers based on whether it is a class or not.
asfgit pushed a commit that referenced this pull request Jul 4, 2014
… defined classes.

This is an alternate solution to #1176.

Author: Prashant Sharma <prashant.s@imaginea.com>

Closes #1179 from ScrapCodes/SPARK-1199/repl-fix-second-approach and squashes the following commits:

820b34b [Prashant Sharma] Here we generate two kinds of import wrappers based on whether it is a class or not.
(cherry picked from commit d434150)

Signed-off-by: Patrick Wendell <pwendell@gmail.com>
xiliu82 pushed a commit to xiliu82/spark that referenced this pull request Sep 4, 2014
… defined classes.

This is an alternate solution to apache#1176.

Author: Prashant Sharma <prashant.s@imaginea.com>

Closes apache#1179 from ScrapCodes/SPARK-1199/repl-fix-second-approach and squashes the following commits:

820b34b [Prashant Sharma] Here we generate two kinds of import wrappers based on whether it is a class or not.
@ScrapCodes
ScrapCodes deleted the SPARK-1199/repl-case-class-fix branch June 3, 2015 06:01
mapr-devops pushed a commit to mapr/spark that referenced this pull request May 8, 2025
mapr-devops pushed a commit to mapr/spark that referenced this pull request May 8, 2025
This reverts commit b9984350a3d2b706db92e50253d66c75f4304bb2.
github-actions Bot pushed a commit to MaxGekk/spark that referenced this pull request Oct 31, 2026
…pache#1176)

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

Step 1 of row 481's approved plan (`sql/varka/plans/m8/VARKA-481.md`, section 8): a `NULL` mode on the IR's `GuardedRange`, with its oracle, grammar, specs and proof. No compiled expression uses it yet, and no emitted byte moves.

`GuardedRange` checks that a lane's value lies within a range. Today it has one disposition, `FAIL`: an out-of-range valid lane declines the batch, and Spark's row engine raises. The new `NULL` mode instead makes an out-of-range lane null, which is what Spark's TRY mode does with an overflow. Row 481's next steps route an ANSI or TRY `TINYINT`/`SMALLINT` multiply through this guard. Rows 332, 343 and 349 take the same mode for their TRY nulls rather than each building their own.

- **The node.** `GuardedRange` takes an `Overflow` mode. The three-argument constructor still builds `FAIL`, so every existing construction site is unchanged, and the constructor refuses `WRAP`. `withChildren` carries the mode. A `NULL` guard renders as `(guardedRange:NULL ...)`, and a `FAIL` guard renders exactly as before, so no existing shape key or class name changes. The cost model gets a separate, unpriced `GuardedRange/NULL/<lane>` feature.
- **How it is emitted.** It follows a `NULL` `IntArith`:
  - It registers no refusal, so it sets no status bit.
  - It owns a validity word, which the liveness pass keeps.
  - It marks the kernel as able to null a valid input, so the kernel has no dense body.
  - It parks its value in its own slot.

  The walk shares its two range compares with the `FAIL` guard, through a new `emitRangeMask`, then clears the out-of-range lanes through `emitOverflowMask`'s `NULL` arm. `guardsStoredValues` now requires `FAIL`, so a `NULL` guard is never taken for the date column's bound.
- **The oracle, specs and parser.** The reference evaluator nulls out-of-range values at the int and long lanes. `VarkaGuardSpecs` notes that a `NULL` guard is not a guard. `VarkaCanonicalIr` parses the new tag.
- **The proof.** `narrow_range.smt2` gains the claim that `word & ~mask` keeps a lane valid exactly when it was valid and in range, over 16 lanes, for byte and short, with two wrong variants that must fail.
- **The fuzz grammar** draws the mode in two new draws with their own seed, not in the existing ones. The existing draws are pinned by `emitted_bytes.json` and the cost tables, and drawing the mode there moves every block. As a result, until step 3 (which moves those bytes anyway and folds the mode into the main draws), no pinned draw reaches a `NULL` guard. The case of an int-lane guard inside a long-lane kernel is covered by an explicit mixed-lane test.

### Why are the changes needed?

TRY's null on overflow has no in-kernel form today. So a TRY narrow multiply, a `try_cast` of a bigint, a floating cast's TRY null and decimal arithmetic under TRY either stay on Spark's row path or would each need a null disposal of their own. This builds the one form they share, first and alone, so it can be verified without any byte moving.

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

No. No compiled expression builds the new mode yet.

### How was this patch tested?

**New tests:**
- every `TINYINT` pair (2^16) and the `SMALLINT` edge values through the step-3 tree (widen, wrapping multiply, `NULL` guard, narrow), on both lane arms, against a reference first checked against Spark's TRY rule;
- an int-lane guard read by a sum, a comparison, a pick, a choice and a `FAIL` guard;
- the long lane at both widths, and the `WRAP` refusal;
- a mixed-lane kernel;
- `withChildren` and the parser round trip;
- the two new fuzz draws against the reference.

**Existing outputs:** `VarkaEmittedBytesSuite`, `VarkaCoverageSuite` and `VarkaEmitCostSuite` pass. `emitted_bytes.json`, `coverage.json` and the cost tables are unchanged.

**Proofs:** `dev/varka_prove.sh --solver both` holds all 16 checks. The run used solver binaries from another worktree; CI's install-and-prove run is the authoritative one.

**Not covered locally:** the sql/core suites weren't built or run. This PR's Build and option matrix ran them.

**The measurement:** `VarkaNarrowEmitBenchmark` on an AMD EPYC 7763 runner through `benchmark.yml`, at 256 bits (run 41142934207) and at 128 bits with `-XX:MaxVectorSize=16` (run 41165599291), both on head `23c26374efe`. The results replace the baseline committed by apache#1177 on the unchanged code. Every checked narrow multiply shape (`y1 * y2` and `s1 * s2` in ANSI and TRY, and `y1 * y2 < y3`) is within 2% of the baseline at both widths, and the widened and native arms tie at 256 bits, as the plan predicted. Four shapes the change does not touch moved by 4% to 23% at 256 bits, in both directions: that is the runners' spread, and the largest move, the selection at a million rows, was an outlier in the baseline itself.

**Linters:** errorprone, lint-java, lint-scala, the plan lint and the quote check are clean.

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

Generated-by: Claude Code (Opus 5.5)
github-actions Bot pushed a commit to MaxGekk/spark that referenced this pull request Nov 11, 2026
…en (apache#1494)

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

This PR marks two plan rows Done in `sql/varka/plans/m8/PLAN.md`: row 329, the `TINYINT` and `SMALLINT` lanes (a widened int-lane arm and a native byte/short arm, behind the emit option `narrowLanes`), and row 330, their arithmetic (`+`, `-`, `*`, negation, `abs` and the `try_` forms) in `LEGACY`, `ANSI` and `TRY`. Both were merged in October 2026 (apache#987, apache#989 and follow-ups). It changes no code. It also adds one new plan row, 603, for a slowdown the check found (below).

New section 9.11 of `sql/varka/plans/m8/VARKA-329.md` checks each row's done-when condition by condition against master, citing the merged PRs, the suites and their test lines, the committed results files and existing CI runs:

- **Row 329.** Both arms are built with their coverage rows. The arms are measured per width and operator, on the laptop and on the EPYC 7763 runner at 256 and 128 bits. The widened arm, which lost, stays in the option matrix as `narrowLanes=false`. The census check passes. The EPYC benchmark covers `TINYINT` only; `SMALLINT` is measured on the laptop. Every byte and short operator-census cell reads intrinsic on the laptop, on the EPYC 7763 and on the Arm runner, or skips by design. The runner columns were only an artifact of the width-audit run 42750857065 (master `159d9b3026e`), and artifacts expire. This PR commits them unchanged as `results/VARKA-329-census-epyc-7763.json` and `results/VARKA-329-census-ubuntu-24.04-arm.json`.
- **Row 330.** Every condition holds, with three qualifications:
  1. The 18 exhaustive `SMALLINT` sweeps (2^32 operand pairs each) run weekly, not nightly, by the owner's decision of 6 November 2026. All 18 passed on both runner types in scheduled run 42355859989.
  2. The `ANSI` sweeps, of both types, check the batch-level decline, not each pair. Per-pair overflow detection is carried by the `TRY` sweeps, which read the same overflow mask (`VarkaVectorWalk.emitNarrowOverflowMask`, then `emitOverflowMask` by mode).
  3. The row asked for its sweep budget in `PLAN.md` before the next sweep landed. It never got there, and 9.4 claimed it had. This PR writes it into `PLAN.md` 10.3 item 5 and adds a dated correction to 9.4. The milestone-wide total covers the sweep manifest as of 7 November only: the float-cast and rounding sweeps are untimed, and row 332's planned sweeps are not counted.

The budget comes from the printed per-sweep lines of run 42355859989, which this PR commits as `results/VARKA-330-sweep-ci.txt`. The 18 `SMALLINT` sweeps take 3544 s of x86 runner time and 4356 s on Arm, against the 5 h 32 min serial floor extrapolated on 22 October from one 1106 s laptop sweep. They run as three operator shards, so the wall clock is the longest shard, 1665 s, after a 633 s build job. The whole sweep manifest took 10506 s of x86 runner time and 61 minutes of wall clock.

What stays open, outside both done-when lists, is listed in 9.11:

- no benchmark on the Neoverse N2;
- at 128 bits on the EPYC 7763, the narrow stores are slow: 150 to 156 M rows/s on the widened arm, and 131 to 139 M rows/s for the checked `TINYINT` multiply on both arms, the default included, against 19 to 40 G rows/s for the default arm's other byte stores; this is consistent with row 479's masked-store account but recorded by neither row 479 nor row 481;
- the unexplained 128-bit bimodality;
- the emitted packed-boolean column, which is row 27's;
- the commits since the last sweep, which next Saturday's run covers.

**New row 603.** The checked `TINYINT` multiply's slowdown above had no owner, so this PR adds a plan row for it. The numbers come from the committed EPYC 7763 results of `VarkaNarrowEmitBenchmark` (`sql/catalyst/benchmarks/VarkaNarrowEmitBenchmark-jdk25-runner-epyc7763-128bit-results.txt` and its 256-bit twin, both from apache#1176). At 128 bits, `y1 * y2` under `ANSI` and `try_multiply(y1, y2)` store 131 to 139 M rows/s on both arms. That is 138 to 308 times slower than the default arm's other byte stores in the same file, and 31 to 36 times slower than the same two shapes at 256 bits. The `SMALLINT` multiplies are not affected (about 1965 and 4530 M rows/s), and neither is the same byte multiply feeding a filter with no byte store (about 816). So the slowdown follows a byte store from a kernel that computes on four int lanes. The operator census misses it too: no cell reads a masked narrow store, so every cell those kernels rest on reads intrinsic. Row 479 rewrites the same 128-bit loop; if its fix removes this masked store, row 603 closes on that rerun. The row's done-when has three steps. First, add a census cell for the masked byte store of a kernel that computes on four int lanes. Second, establish the cause from HotSpot's own output on x86 under `-XX:UseAVX=2 -XX:MaxVectorSize=16`: `-XX:+PrintIntrinsics`, `-XX:+PrintCompilation` and the Vector API's intrinsic-failure lines show whether the byte store and its mask are compiled to vector instructions at that width, or fall back to Java and allocate. Third, either fix the store and rerun the two shapes at both widths, or decline the shape on such hosts with the measured reason.

**Review points left as they are.** A high-effort review raised these. They are judgement calls for the owner, not errors in the record:

- Row 329 reads Done although its benchmark condition holds in part: the EPYC 7763 files cover `TINYINT` only, `VarkaNarrowLaneBenchmark` has no committed results file (its laptop numbers are text records), and the Neoverse N2 has no benchmark. The record states each limit.
- Row 330 reads Done although its full 2^32 sweeps last ran at `0b682025e09`. Eight later commits touched the narrow emission or its suite, so until next Saturday's run only the 2^24 slices on every build cover them. Two conditions are also met only in a qualified form, weekly rather than nightly and the budget totalled late. Each is stated in the row, so the owner may prefer "Done, with a waiver" or amended done-when text instead.
- `VARKA-332.md` still says the budget is missing from `PLAN.md` and sizes its 38 sweeps at the 1106 s floor. This PR leaves row 332's file to row 332.
- The skills notes' runner table still cites the older width-audit run 39400866095 and does not list the `F` cells the new run shows (`long.ABS` at 256 bits on the EPYC 7763; more long and decimal cells at 128 bits). Bringing that table up to date belongs to the next skills upkeep, not this close.
- The 128-bit bimodality, the Neoverse N2 benchmark and a runner measurement of `SMALLINT` stay without a row of their own. This PR adds only row 603.

### Why are the changes needed?

The two rows were built and merged weeks ago but still read Started, so the plan claimed work was left on them. The one real gap was the sweep budget. Planning for later sweeps (`VARKA-332.md` 0 item 14) found it missing from `PLAN.md`. Until now the only number written down was a serial floor of 5.5 hours, about five times the measured runner time.

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

No. It changes plan text, adds one plan row, adds three results files and updates one sentence of the Vector API skills notes (`sql/varka/skills/vector-api-and-width.md`) to point at the committed runner census columns.

### How was this patch tested?

- `dev/varka_plan_lint.py --check`, with the run citations checked online: no findings.
- `python3 dev/varka_push_check.py`: passed, covering pre-commit, the quote check, `dev/varka_census.py --check` and the size check (111 counted lines).
- Every number in 9.11 was read from the committed files or the cited CI runs' job steps, logs and artifacts. No sweep or benchmark was rerun.

### 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.

2 participants