Skip to main content
sonnh
Silver ⭐️⭐️⭐️
Aug 14, 2023 8:34 AM UTC
Solved

How to get spark.executor.memory size of spark session?

I am using Spark 2.3.2.3.1.0.0-78.
I tried to use:
spark_session.sparkContext._conf.get('spark.executor.memory')
but I only received 'None'.

Can someone help me, please?

RangaReddy
Gold ⭐️
Aug 17, 2023 5:27 AM UTC

Hi @sonnh 

 

If you do not specify spark.executor.memory when using spark-submit or spark-shell, or pyspark, the default value for spark.executor.memory will be set to 1g.

 

Launch the Spark Shell by passing the Executor Memory:

 

 

 

[root@local ~]# pyspark --conf spark.executor.memory=1g
>>> spark.conf.get("spark.executor.memory")
u'1g'

 

 
Launch the Spark Shell by without passing the Executor Memory:
 

 

[root@local ~]# pyspark
>>> spark.conf.get("spark.executor.memory")
py4j.protocol.Py4JJavaError: An error occurred while calling o66.get. :
java.util.NoSuchElementException: spark.executor.memory ...

 

Note: Spark is not able to detect/load the spark.executor.memory parameter value from launched spark shell.

 

Reference:

 

https://spark.apache.org/docs/latest/configuration.html

4 replies

RangaReddy
Gold ⭐️
Gold ⭐️
Aug 17, 2023 5:27 AM UTC

Hi @sonnh 

 

If you do not specify spark.executor.memory when using spark-submit or spark-shell, or pyspark, the default value for spark.executor.memory will be set to 1g.

 

Launch the Spark Shell by passing the Executor Memory:

 

 

 

[root@local ~]# pyspark --conf spark.executor.memory=1g
>>> spark.conf.get("spark.executor.memory")
u'1g'

 

 
Launch the Spark Shell by without passing the Executor Memory:
 

 

[root@local ~]# pyspark
>>> spark.conf.get("spark.executor.memory")
py4j.protocol.Py4JJavaError: An error occurred while calling o66.get. :
java.util.NoSuchElementException: spark.executor.memory ...

 

Note: Spark is not able to detect/load the spark.executor.memory parameter value from launched spark shell.

 

Reference:

 

https://spark.apache.org/docs/latest/configuration.html

Translate
sonnh
sonnhAuthor
Silver ⭐️⭐️⭐️
Aug 18, 2023 7:23 AM UTC

Tks @RangaReddy  My purpose is to collect a series of pagings from an RDBMS and compare it with JVM_HEAP_MEMORY. Do you find this approach acceptable? I believe it could help alleviate the issue of small files on HDFS.  I'm facing difficulties in calculating the size of the DataFrame. It seems there's no straightforward way to accomplish it

Translate
RangaReddy
Gold ⭐️
Gold ⭐️
Aug 20, 2023 3:54 PM UTC

To calculate the DataFrame size, you can use SizeEstimator class.

Translate