spark-lightning-optimization
Skill138 starsChanged 5 months agoApache-2.0View on GitHub
This skill establishes the configuration practices for executing PySpark workloads on Managed Service for Apache Spark Serverless. To achieve optimal performance, workloads should leverage the Spark Lightning Engine (vectorized execution) and Spark Connect for decoupled session management. When configuring Spark sessions: 1. Enforce Lightning Engine: Always configure the session to use lightningEngine. 2. Enforce Premium Tier: Set the runtime to premium. 3. Use Spark Connect: Prefer DataprocSparkSession over standard SparkSession when working with Serverless Spark to support modern decoupled execution.
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
When configuring Spark sessions:
- Very specific: line 26
Enforce Lightning Engine: Always configure the session to use lightningEngine.
- Very specific: line 29
Use Spark Connect: Prefer DataprocSparkSession over standard SparkSession when working with Serverless Spark to support modern decoupled …
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: Serverless Spark & Lightning Engine Optimization
<!--
Disabling markdownlint MD029 to provide explicit ordering to avoid
confusing the LLM.
--><!-- markdownlint-disable MD029 -->1. Description & Rationale
This skill establishes the configuration practices for executing PySpark workloads on Managed Service for Apache Spark Serverless. To achieve optimal performance, workloads should leverage the Spark Lightning Engine (vectorized execution) and Spark Connect for decoupled session management.
2. Environment Prerequisites
- Execution Engine: Managed Service for Apache Spark Serverless.
- Tier: Premium (required for Lightning Engine).
- SDK:
google-cloud-dataproc(specifically for Spark Connect).
3. Agent Execution Guidelines (System Prompts)
When configuring Spark sessions:
- Enforce Lightning Engine: Always configure the session to use
lightningEngine. - Enforce Premium Tier: Set the runtime to
premium. - Use Spark Connect: Prefer
DataprocSparkSessionover standardSparkSessionwhen working with Serverless Spark to support modern decoupled execution.
4. Opinionated Code Patterns
A. Creating the Optimized Spark Session
The agent must use the following pattern to initialize the Spark session:
from google.cloud.dataproc_spark_connect import DataprocSparkSession
from google.cloud.dataproc_v1 import Session
def create_spark_session():
"""Creates a SparkSession with BigQuery and GCS support using Lightning Engine."""
session = Session()
session.runtime_config.version = "3.0" # Adjust version if needed
# Enable premium tier and lightning engine
session.runtime_config.properties = {
"dataproc.runtime": "premium",
"spark.dataproc.engine": "lightningEngine",
"spark.dynamicAllocation.maxExecutors": "8",
}
spark = (
DataprocSparkSession.builder.appName("Detox-Spark-Demo")
.dataprocSessionConfig(session)
.getOrCreate()
)
return spark
spark = create_spark_session()
print("AI-Native Spark Session Created with Lightning Engine")5. Verification Checklist
- Premium Tier: Verify
"dataproc.runtime": "premium"is in the properties. - Lightning Engine: Verify
"spark.dataproc.engine": "lightningEngine"is set. - Spark Connect: Ensure
DataprocSparkSessionis used instead ofpyspark.sql.SparkSession.
In this repository28 other files it gives its agents.
- spanner-provisioningSkill
- ad-copywritingSkill
- brand-strategySkill
- platform-specsSkill
- trend-analysisSkill
- video-storytellingSkill
- visual-directionSkill
- ad-copywritingSkill
- brand-strategySkill
- platform-specsSkill
- trend-analysisSkill
- video-storytellingSkill
- visual-directionSkill
- code-reviewSkill
- documentationSkill
- idea-to-appSkill
- open-prSkill
- pre-commitSkill
- security-scanSkill
- unit-testsSkill
- modernize-dotnet-cloudrunSkill
- legacy-app-generatorSkill
- ingress2gatewaySkill
- bigframes-bqmlSkill
- model-evaluationSkill
- pipeline-generatorSkill
- unified-model-registrySkill
- zero-copy-ingestionSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

