Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Optimize Apache Spark jobs with partitioning, caching, shuffle optimization, and memory tuning. Use when improving Spark performance, debugging slow jobs, or scaling data processing pipelines.
.claude/skills/wshobson-spark-optimization/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 15% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 22% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 18% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 44% | 0% |
Production patterns for optimizing Apache Spark jobs including partitioning strategies, memory management, shuffle optimization, and performance tuning.
Driver Program
↓
Job (triggered by action)
↓
Stages (separated by shuffles)
↓
Tasks (one per partition)| Factor | Impact | Solution | | ----------------- | --------------------- | ----------------------------- | | Shuffle | Network I/O, disk I/O | Minimize wide transformations | | Data Skew | Uneven task duration | Salting, broadcast joins | | Serialization | CPU overhead | Use Kryo, columnar formats | | Memory | GC pressure, spills | Tune executor memory | | Partitions | Parallelism | Right-size partitions |
pythonfrom pyspark.sql import SparkSession from pyspark.sql import functions as F # Create optimized Spark session spark = (SparkSession.builder .appName("OptimizedJob") .config("spark.sql.adaptive.enabled", "true") .config("spark.sql.adaptive.coalescePartitions.enabled", "true") .config("spark.sql.adaptive.skewJoin.enabled", "true") .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer") .config("spark.sql.shuffle.partitions", "200") .getOrCreate()) # Read with optimized settings df = (spark.read .format("parquet") .option("mergeSchema", "false") .load("s3://bucket/data/")) # Efficient transformations result = (df .filter(F.col("date") >= "2024-01-01") .select("id", "amount", "category") .groupBy("category") .agg(F.sum("amount").alias("total"))) result.write.mode("overwrite").parquet("s3://bucket/output/")
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
.count() for existence - Use .take(1) or .isEmpty()| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | pass→pass | 16,580 | 13,437 | -19% | 1 | 1 | 0% | 2,720 | 3,317 | +22% | 0 | 0 | — |
case-01 | fail→pass | 20,430 | 19,291 | -6% | 1 | 1 | 0% | 3,654 | 4,215 | +15% | 0 | 0 | — |
case-02 | pass→pass | 12,591 | 10,015 | -20% | 1 | 1 | 0% | 2,561 | 3,011 | +18% | 0 | 0 | — |
case-04 | pass→pass | 9,490 | 10,622 | +12% | 1 | 1 | 0% | 1,827 | 2,633 | +44% | 0 | 0 | — |
case-05 | fail→pass | 11,382 | 12,472 | +10% | 1 | 1 | 0% | 2,198 | 3,022 | +37% | 0 | 0 | — |
case-06 | pass→pass | 7,396 | 6,736 | -9% | 1 | 1 | 0% | 1,601 | 2,048 | +28% | 0 | 0 | — |
case-07 | pass→pass | 13,737 | 12,683 | -8% | 1 | 1 | 0% | 2,937 | 3,366 | +15% | 0 | 0 | — |
case-08 | pass→pass | 12,818 | 13,261 | +3% | 1 | 1 | 0% | 2,257 | 3,184 | +41% | 0 | 0 | — |
case-09 | pass→pass | 9,174 | 6,874 | -25% | 1 | 1 | 0% | 1,738 | 2,198 | +26% | 0 | 0 | — |
case-10 | pass→pass | 7,805 | 6,204 | -21% | 1 | 1 | 0% | 1,600 | 1,977 | +24% | 0 | 0 | — |
case-11 | pass→pass | 13,551 | 10,067 | -26% | 1 | 1 | 0% | 2,616 | 2,791 | +7% | 0 | 0 | — |
case-12 | pass→pass | 12,692 | 10,126 | -20% | 1 | 1 | 0% | 2,344 | 2,646 | +13% | 0 | 0 | — |
case-13 | pass→pass | 12,490 | 9,772 | -22% | 1 | 1 | 0% | 2,271 | 2,579 | +14% | 0 | 0 | — |
case-14 | pass→pass | 11,432 | 9,870 | -14% | 1 | 1 | 0% | 2,207 | 2,579 | +17% | 0 | 0 | — |
case-15 | pass→pass | 13,587 | 10,914 | -20% | 1 | 1 | 0% | 2,822 | 2,917 | +3% | 0 | 0 | — |
case-16 | pass→pass | 12,157 | 14,970 | +23% | 1 | 1 | 0% | 2,575 | 3,195 | +24% | 0 | 0 | — |
case-17 | pass→pass | 5,799 | 7,027 | +21% | 1 | 1 | 0% | 1,187 | 2,195 | +85% | 0 | 0 | — |
case-18 | pass→pass | 13,429 | 10,584 | -21% | 1 | 1 | 0% | 2,398 | 2,701 | +13% | 0 | 0 | — |
case-19 | pass→pass | 10,879 | 7,801 | -28% | 1 | 1 | 0% | 2,350 | 2,307 | -2% | 0 | 0 | — |
case-20 | pass→pass | 13,665 | 10,535 | -23% | 1 | 1 | 0% | 2,808 | 3,055 | +9% | 0 | 0 | — |
case-21 | pass→pass | 18,256 | 17,507 | -4% | 1 | 1 | 0% | 3,181 | 3,511 | +10% | 0 | 0 | — |
case-22 | pass→pass | 14,889 | 15,745 | +6% | 1 | 1 | 0% | 2,704 | 3,415 | +26% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.