Title
Page icon
Create new category
Edit page index title
Edit category
Edit link
Run Spark with Velox
You can use Velox with Spark 3.5.5 and Spark 4.1.1 to accelerate Spark SQL workloads. Gluten provides the Spark plugin that offloads supported SQL operations to the Velox native execution engine.
To enable Gluten and Velox, you must configure:
Without this configuration, Velox isn't enabled.
Prerequisites
Before you submit an application:
Set
SPARK_HOMEto the client for the Spark version that you want to use.For Spark 3.5.5:
export SPARK_HOME=/usr/odp/current/spark3-clientFor Spark 4.1.1:
export SPARK_HOME=/usr/odp/current/spark4-clientUse Parquet or ORC data for better performance.
Enable off-heap memory for Velox:
spark.memory.offHeap.enabled=trueConfigure sufficient off-heap memory for the YARN container.
The examples on this page use
2g. For larger workloads, increase the value as required.
Run Spark 3.5.5 with Velox
Gluten JAR
On ODP, the Gluten bundle is typically available in the Spark 3 jars directory:
Important: If the Gluten JAR is already in the Spark 3
jarsdirectory, don't specify the same JAR by using--jars. Loading the JAR more than once can cause aduplicate VeloxBackenderror.
Submit a Spark application
Set SPARK_HOME:
On JDK 11 environments, configure the required Java options:
Submit the application:
Run Spark SQL
Disable broadcast joins
On some JDK 11 environments, Gluten columnar broadcast operations can fail with the following error:
To avoid this issue, the preceding examples disable broadcast joins:
You can enable broadcast joins if your JDK and Gluten build support them.
Run Spark 4.1.1 with Velox
Spark 4.1.1 has the following requirements that differ from Spark 3.5.5:
Spark 4.1.1 requires JDK 17 for the YARN ApplicationMaster and executors.
The Gluten JAR might not be in the Spark 4
jarsdirectory. In this case, specify it by using--jars.
Configure JDK 17
Set the Spark 4 client:
Set the JDK 17 installation directory:
If multiple JDK 17 installations are available, specify the complete installation path.
For example:
Locate the Gluten JAR
The Gluten JAR is typically available at a path similar to:
The build number can vary depending on your ODP installation.
You can locate the JAR by running:
Submit a Spark application
Run Spark SQL
Note: When you use
spark-sqlwith Spark 4.1.1, don't specify both-eand-fin the same command. Use either-eor-f.
Velox configuration
The following configurations apply to both Spark versions:
Configuration | Value | Description |
|---|---|---|
|
| Loads the Gluten plugin. |
|
| Enables Gluten. |
|
| Uses Velox as the columnar backend. |
|
| Enables off-heap memory for native processing. |
|
| Specifies the amount of off-heap memory available to the native buffer pool. |
|
| Enables the columnar shuffle manager. |
You can also configure the following optional properties:
Verify that Velox is enabled
After you submit an application, verify that Gluten and Velox loaded successfully.
Open the Spark UI.
Go to Environment.
Verify that the following configuration is present:
spark.plugins=org.apache.gluten.GlutenPluginRun
df.explain(true)orEXPLAIN EXTENDED.Check the execution plan for Gluten operators, such as:
GlutenScan GlutenFilter GlutenProjectCheck the driver logs for messages that indicate that Gluten and Velox loaded successfully.
If the execution plan contains only standard Spark operators and doesn't contain Gluten operators, verify the Gluten configuration and JAR location.
Troubleshoot Velox
Issue | Resolution |
|---|---|
Gluten plugin isn't found | Verify |
| Don't specify the Gluten bundle with |
| Configure JDK 17 for the ApplicationMaster and executors. |
Out-of-memory or memory allocation errors | Increase |
Incorrect results or unsupported query | Set |
History Server errors after adding Gluten to the Spark 4 | Keep the Gluten JAR outside the Spark 4 |
Disable Velox
To run an application without Velox, remove the spark.plugins and Gluten-specific configurations.
Alternatively, disable Gluten for the application:
The application then runs using the standard Spark execution engine.