Skip to content

[SPARK-54449][CORE] Storage Memory off heap size should be considered only when off heap is enabled#53383

Open
VindhyaG wants to merge 20 commits intoapache:masterfrom
VindhyaG:SPARK-54449
Open

[SPARK-54449][CORE] Storage Memory off heap size should be considered only when off heap is enabled#53383
VindhyaG wants to merge 20 commits intoapache:masterfrom
VindhyaG:SPARK-54449

Conversation

@VindhyaG
Copy link
Contributor

@VindhyaG VindhyaG commented Dec 8, 2025

What changes were proposed in this pull request?

Currently, even if spark.memory.offHeap.enabled=false
spark.memory.offHeap.size is calculated for SPARK UI and wherever the config is used. This PR changes the logic to take the value set in spark.memory.offHeap.size only when spark.memory.offHeap.enabled

Why are the changes needed?

Change the logic to get the config of spark.memory.offHeap.size by checking spark.memory.offHeap.enabled first

Does this PR introduce any user-facing change?

Yes. Spark UI will show the total of Onheap and Off heap memory only if spark.memory.offHeap.enabled = true.

How was this patch tested?

Existing UTs

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

No

@github-actions github-actions bot added the CORE label Dec 8, 2025
@VindhyaG VindhyaG changed the title [SPARK-54449][SPARK-UI] : Storage Memory off heap size should be considered only when off heap is enabled [SPARK-54449][CORE] : Storage Memory off heap size should be considered only when off heap is enabled Dec 8, 2025
@VindhyaG VindhyaG changed the title [SPARK-54449][CORE] : Storage Memory off heap size should be considered only when off heap is enabled [SPARK-54449][CORE] Storage Memory off heap size should be considered only when off heap is enabled Dec 8, 2025
@VindhyaG VindhyaG force-pushed the SPARK-54449 branch 2 times, most recently from 095d819 to db76a5d Compare December 9, 2025 13:05
@VindhyaG VindhyaG force-pushed the SPARK-54449 branch 2 times, most recently from dde0469 to 7f06280 Compare December 12, 2025 04:50
@VindhyaG
Copy link
Contributor Author

VindhyaG commented Dec 16, 2025

@holdenk @pan3793 can you please help review this or help tag the relevant reviewers please ? Thanks!

@qiaojizhen
Copy link

I have also noticed this problem and I think it is necessary to correct it!
image
image

@qiaojizhen
Copy link

qiaojizhen commented Jan 23, 2026

@VindhyaG
I have found another issue.
If spark.memory.offHeap.enabled = true, the Driver actually won't apply the offHeap memory in any cluster deploy mode.
But now the Driver is displaying the number which is set by spark.memory.offHeap.size.
So I think the Driver in the web ui should display zero for "Off Heap Memory".
Could u please solve this problem in this PR by the way?
Thanks!

@VindhyaG
Copy link
Contributor Author

VindhyaG commented Jan 29, 2026

@VindhyaG I have found another issue. If spark.memory.offHeap.enabled = true, the Driver actually won't apply the offHeap memory in any cluster deploy mode. But now the Driver is displaying the number which is set by spark.memory.offHeap.size. So I think the Driver in the web ui should display zero for "Off Heap Memory". Could u please solve this problem in this PR by the way? Thanks!

@qiaojizhen I did not get what you mean by Driver won't aply offheap in cluster mode. Is it not supported in cluster mode you mean?

@VindhyaG
Copy link
Contributor Author

VindhyaG commented Feb 2, 2026

I have also noticed this problem and I think it is necessary to correct it! image image

@qiaojizhen Sorry I did not get what is the exact issue here? The value shown for the total memory size should get fixed with the changes done already.

bmConf.set(TEST_MEMORY, maxMem)
bmConf.set(MEMORY_OFFHEAP_SIZE, maxMem)
if(maxMem > 0) {
bmConf.set(MEMORY_OFFHEAP_ENABLED, true)
Copy link
Member

Choose a reason for hiding this comment

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

Why does MEMORY_OFFHEAP_ENABLED depend on maxMem?

Copy link
Contributor Author

@VindhyaG VindhyaG Feb 3, 2026

Choose a reason for hiding this comment

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

This is for the UTs wtih the tests where if maxMem set specifically greather than 0 only then set the MEMORY_OFFHEAP_ENABLED to true else keep it default false. Earlier MEMORY_OFFHEAP_ENABLED was always set to default false and only MEMORY_OFFHEAP_SIZE value was used to test all the combinations because earlier MEMORY_OFFHEAP_ENABLED true needed MEMORY_OFFHEAP_SIZE > 0 and not vice versa. MEMORY_OFFHEAP_ENABLED value did not matter at all for MEMORY_OFFHEAP_SIZE tests. We cannot do that with this change where if MEMORY_OFFHEAP_ENABLED is false maxMem is essentially zero as well.

Copy link
Member

@Ngone51 Ngone51 left a comment

Choose a reason for hiding this comment

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

The fix looks good to me overall. Could you post the UI screenshots before and after the fix to show the straightforward difference from UI?

@qiaojizhen
Copy link

@VindhyaG I have found another issue. If spark.memory.offHeap.enabled = true, the Driver actually won't apply the offHeap memory in any cluster deploy mode. But now the Driver is displaying the number which is set by spark.memory.offHeap.size. So I think the Driver in the web ui should display zero for "Off Heap Memory". Could u please solve this problem in this PR by the way? Thanks!

@qiaojizhen I did not get what you mean by Driver won't aply offheap in cluster mode. Is it not supported in cluster mode you mean?

@VindhyaG Yes! The off-heap memory won't work for Driver in any cluster mode!
If I use the following config:

spark.driver.memory=1g 
spark.driver.memoryOverhead=1g 
spark.memory.offHeap.enabled=true
spark.memory.offHeap.size=2g

when I submit the job to YARN, the Driver container only gets 2G memory(including spark.driver.memory & spark.driver.memoryOverhead):
image

but the web ui still display the off-heap memory:
image

and the soucre code here Spark Yarn Client has proved that it will only use spark.driver.memory & spark.driver.memoryOverhead when applying the AM memory:
image

@VindhyaG
Copy link
Contributor Author

VindhyaG commented Feb 3, 2026

The fix looks good to me overall. Could you post the UI screenshots before and after the fix to show the straightforward difference from UI?

@Ngone51 Before the change

Screenshot 2026-02-03 at 5 26 25 PM Before

After

After

@VindhyaG
Copy link
Contributor Author

VindhyaG commented Feb 4, 2026

@VindhyaG I have found another issue. If spark.memory.offHeap.enabled = true, the Driver actually won't apply the offHeap memory in any cluster deploy mode. But now the Driver is displaying the number which is set by spark.memory.offHeap.size. So I think the Driver in the web ui should display zero for "Off Heap Memory". Could u please solve this problem in this PR by the way? Thanks!

@qiaojizhen I did not get what you mean by Driver won't aply offheap in cluster mode. Is it not supported in cluster mode you mean?

@VindhyaG Yes! The off-heap memory won't work for Driver in any cluster mode! If I use the following config:

spark.driver.memory=1g 
spark.driver.memoryOverhead=1g 
spark.memory.offHeap.enabled=true
spark.memory.offHeap.size=2g

when I submit the job to YARN, the Driver container only gets 2G memory(including spark.driver.memory & spark.driver.memoryOverhead): image

but the web ui still display the off-heap memory: image

and the soucre code here Spark Yarn Client has proved that it will only use spark.driver.memory & spark.driver.memoryOverhead when applying the AM memory: image

@qiaojizhen So basically, Driver will not have off heap no matter the setting. Is that correct? Should we not have something like NA/null (- in UI) will be more clear I suppose. Or should we just make it 0?

@qiaojizhen
Copy link

@VindhyaG I have found another issue. If spark.memory.offHeap.enabled = true, the Driver actually won't apply the offHeap memory in any cluster deploy mode. But now the Driver is displaying the number which is set by spark.memory.offHeap.size. So I think the Driver in the web ui should display zero for "Off Heap Memory". Could u please solve this problem in this PR by the way? Thanks!

@qiaojizhen I did not get what you mean by Driver won't aply offheap in cluster mode. Is it not supported in cluster mode you mean?

@VindhyaG Yes! The off-heap memory won't work for Driver in any cluster mode! If I use the following config:

spark.driver.memory=1g 
spark.driver.memoryOverhead=1g 
spark.memory.offHeap.enabled=true
spark.memory.offHeap.size=2g

when I submit the job to YARN, the Driver container only gets 2G memory(including spark.driver.memory & spark.driver.memoryOverhead): image
but the web ui still display the off-heap memory: image
and the soucre code here Spark Yarn Client has proved that it will only use spark.driver.memory & spark.driver.memoryOverhead when applying the AM memory: image

@qiaojizhen So basically, Driver will not have off heap no matter the setting. Is that correct? Should we not have something like NA/null (- in UI) will be more clear I suppose. Or should we just make it 0?

@VindhyaG Yes, in cluster mode, the Off-Heap of the Driver does not take effect regardless of whether the setting is enabled or not. I think "make it 0" is consistent with the existing logic.

@VindhyaG
Copy link
Contributor Author

VindhyaG commented Feb 6, 2026

@qiaojizhen have done the changes for the driver Off heap values. Can you please revew the PR ?
@Ngone51 have attached the screenshots of before and after changes. Can you please review?

@VindhyaG
Copy link
Contributor Author

VindhyaG commented Feb 6, 2026

When the off heap toggle is set to true

Screenshot 2026-02-06 at 3 32 47 PM

@VindhyaG
Copy link
Contributor Author

@dongjoon-hyun can you please help point to a relevant reviewer for this PR?

Copy link
Contributor

@holdenk holdenk left a comment

Choose a reason for hiding this comment

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

Seems reasonbale ish, although should we log a warning when off-heap is configured and disabled?

Comment on lines +887 to +888
if (event.blockManagerId.executorId == SparkContext.DRIVER_IDENTIFIER) {
exec.totalOffHeap = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it true the driver would never use off heap storage?

Copy link
Contributor Author

@VindhyaG VindhyaG Feb 24, 2026

Choose a reason for hiding this comment

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

@holdenk The reference I took from https://spark.apache.org/docs/latest/configuration.html mentions only executor. @qiaojizhen can you please confirm again?

Choose a reason for hiding this comment

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

@holdenk @VindhyaG
In the cluster deployment mode, it is indeed so. In local mode, the Driver still uses off heap memory. But I think it will be ok to display zero for the Drvier off heap memory!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants