Thursday - last edited Thursday
I have a Unity Catalog Enabled cluster with Node type Standard_DS4_v2 (28 GB Memory, 8 Cores). When "Use Photon Acceleration" option is disabled spark.executor.memory is 18409m. But if I enable Photon Acceleration it shows spark.executor.memory as 4602m. Due to this most of the code which I have written is failing giving an error
org.apache.spark.memory.SparkOutOfMemoryError: Photon ran out of memory while executing this query.
Photon Enabled Cluster:
Photon Disabled Cluster:
Thursday
Enabling Photon Acceleration on your Databricks cluster reduces the available executor memory because Photon uses a different memory management strategy compared to standard Spark. Photon is designed to optimize performance by leveraging the underlying hardware more efficiently, but this comes at the cost of reduced memory allocation for Spark executors.
To address the issue of reduced executor memory when Photon is enabled, you can try the following approaches:
Increase the Node Size: Upgrade your cluster to use larger node types with more memory. For example, you can switch from Standard_DS4_v2
to Standard_DS5_v2
, which provides more memory and CPU resources.
Adjust Spark Configuration: You can fine-tune Spark configurations to optimize memory usage. For instance, increasing the number of shuffle partitions can help distribute the workload more evenly and reduce memory pressure on individual executors. You can set this configuration at the cluster level:
spark.sql.shuffle.partitions 1000
Thursday
@Einsatz thanks for your question!
1) Why does enabling Photon reduce the executor memory?
Photon allocates a significant portion of memory off-heap for its C++ engine. As a result, the on-heap memory (shown by spark.executor.memory) appears lower once Photon is enabled.
2) Is there a way to keep spark.executor.memory at 18409m when Photon is enabled?
Not directly. You must either increase your node’s total memory (e.g., choose a larger instance type) or adjust off-heap allocations to accommodate Photon’s requirements.
Photon is a separate C++ engine embedded within Spark to accelerate certain SQL workloads. So, it requires its own memory space, therefore you can either provision extra memory for Photon or run those queries in the regular Spark engine with full on-heap capacity. It comes with a cost which you need to balance and account accordingly.
yesterday - last edited yesterday
@VZLA/@Walter_C Thanks for the quick answers! I understand that the Photon engine requires memory for its optimization tasks, and this memory usage impacts the executor memory.
I’ve got few more questions, and I’d really appreciate it if you could help me out.
yesterday
The memory allocated to the Photon engine is not fixed; it is based on a percentage of the node’s total memory.
To calculate the value of spark.executor.memory
based on a specific node type, you can use the following formula:
container_size = (vm_size * 0.97 - 4800MB)
spark.executor.memory = (0.8 * container_size)
For your node type, Standard_DS4_v2 (28GB RAM, 8 cores), the calculation would be:
container_size = (28GB * 0.97 - 4800MB)
spark.executor.memory = (0.8 * container_size)
This results in approximately 17.97GB (18409m).
Regarding the 'Storage Memory' column in the Spark UI -> Executors, it represents the amount of memory allocated for storage (caching) within the executor. In your case, it shows 9.4GB, which is half of the total executor memory (18409m). This indicates that 50% of the total executor memory is allocated for storage memory, and the remaining 50% is used for execution memory.
The 'Memory' column in the Spark compute UI - Master -> Workers represents the total memory allocated to the worker node. The 22.5GiB (18.0GiB used) indicates that 18.0GiB corresponds to the spark.executor.memory
value (18409m), and the remaining memory is used by other processes and overheads.
The 'Memory per Executor' column in the Spark compute UI - Master -> Running Applications refers to the memory allocated per executor, which in your case is 18409m. This is the same value as the spark.executor.memory
calculated above
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group