Skip to content

[SPARK-60984][CORE][TESTS] Fix HighlyCompressedMapStatusBenchmark failure when mockito is not on the classpath - #60160

Closed
dongjoon-hyun wants to merge 1 commit into
apache:masterfrom
dongjoon-hyun:SPARK-60984
Closed

dongjoon-hyun wants to merge 1 commit into
apache:masterfrom
dongjoon-hyun:SPARK-60984

Conversation

@dongjoon-hyun

@dongjoon-hyun dongjoon-hyun commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This PR removes the Mockito dependency from HighlyCompressedMapStatusBenchmark.

  • Instead of mocking SparkEnv for each case, the benchmark now starts a single local[1] SparkContext and changes spark.shuffle.accurateBlockSkewedFactor on SparkEnv.get.conf before each case. HighlyCompressedMapStatus reads this value from SparkEnv.get.conf on every call, so the behavior is the same as the mock.
  • The SparkContext is stopped before the "Driver heap retained by MapOutputTracker" report, which creates its own SparkContext.

Why are the changes needed?

The benchmark job fails with:

java.lang.NoClassDefFoundError: org/mockito/Mockito
  at org.apache.spark.HighlyCompressedMapStatusBenchmark$.envWithSkewedFactor(HighlyCompressedMapStatusBenchmark.scala:52)

(https://github.com/dongjoon-hyun/spark/actions/runs/41684094207/job/127686502284)

The GitHub Actions benchmark workflow runs Benchmarks through spark-submit --jars <test jars>. mockito-core is a test-scope dependency of core, so it is not on that classpath. build/sbt "core/Test/runMain ..." does include test dependencies, which is why the failure does not reproduce locally.

The benchmark was added by SPARK-48290 (a125337, 2026-10-19). Other benchmarks do not depend on Mockito.

Does this PR introduce any user-facing change?

No. This only changes a benchmark.

How was this patch tested?

Ran the benchmark locally and confirmed that it completes successfully and that the reported numbers (for example, the bytes retained per map task) are the same as before the change:

build/sbt "core/Test/runMain org.apache.spark.HighlyCompressedMapStatusBenchmark"

The benchmark has not been run through spark-submit --jars yet, so the GitHub Actions benchmark job needs to confirm the fix.

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

Generated-by: Claude Sonnet 5.5

…ailure when `mockito` is not on the classpath
@dongjoon-hyun

Copy link
Copy Markdown
Member Author

cc @Vivek1106-04 , @sunchao , @uros-b

@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Could you review this PR to unblock Java 21 migration, @HyukjinKwon ?

@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Thank you, @HyukjinKwon ~

dongjoon-hyun added a commit that referenced this pull request Nov 6, 2026
…ilure when `mockito` is not on the classpath

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

This PR removes the Mockito dependency from `HighlyCompressedMapStatusBenchmark`.

- Instead of mocking `SparkEnv` for each case, the benchmark now starts a single `local[1]` `SparkContext` and changes `spark.shuffle.accurateBlockSkewedFactor` on `SparkEnv.get.conf` before each case. `HighlyCompressedMapStatus` reads this value from `SparkEnv.get.conf` on every call, so the behavior is the same as the mock.
- The `SparkContext` is stopped before the "Driver heap retained by MapOutputTracker" report, which creates its own `SparkContext`.

### Why are the changes needed?

The benchmark job fails with:

```
java.lang.NoClassDefFoundError: org/mockito/Mockito
  at org.apache.spark.HighlyCompressedMapStatusBenchmark$.envWithSkewedFactor(HighlyCompressedMapStatusBenchmark.scala:52)
```

(https://github.com/dongjoon-hyun/spark/actions/runs/41684094207/job/127686502284)

The GitHub Actions benchmark workflow runs `Benchmarks` through `spark-submit --jars <test jars>`. `mockito-core` is a test-scope dependency of `core`, so it is not on that classpath. `build/sbt "core/Test/runMain ..."` does include test dependencies, which is why the failure does not reproduce locally.

The benchmark was added by SPARK-48290 (a125337, 2026-10-19). Other benchmarks do not depend on Mockito.
- #57528

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

No. This only changes a benchmark.

### How was this patch tested?

Ran the benchmark locally and confirmed that it completes successfully and that the reported numbers (for example, the bytes retained per map task) are the same as before the change:

```
build/sbt "core/Test/runMain org.apache.spark.HighlyCompressedMapStatusBenchmark"
```

The benchmark has not been run through `spark-submit --jars` yet, so the GitHub Actions benchmark job needs to confirm the fix.

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

Generated-by: Claude Sonnet 5.5

Closes #60160 from dongjoon-hyun/SPARK-60984.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
(cherry picked from commit 7af0d94)
Signed-off-by: Dongjoon Hyun <[email protected]>
@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Merge Summary:

Posted by merge_spark_pr.py

@dongjoon-hyun
dongjoon-hyun deleted the SPARK-60984 branch November 6, 2026 06:16
@HyukjinKwon HyukjinKwon removed the ai-review-requested Trigger AI review by Omnigent on Databricks label Nov 8, 2026

@uros-b uros-b left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Late LGTM, thank you for following up on this @dongjoon-hyun!

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.

3 participants