So I looked at a bunch of posts on Pyspark, Jupyter and setting memory/cores/executors (and the associated memory).
But I appear to be stuck -
Question 1: I dont see my machine utilizing either the cores or the memory. Why? Can I do some adjustments to the excutors/cores/memory to optimize speed of reading the file? Question 2: Also is there any way for me to see a progress bar showing how much of the file ahs been imported (spark-monitor doesnt seem to do it).
I am importing a 33.5gb file into pyspark.
Machine has 112 gb or RAM 8 Cores/16 virtual cores.
from pyspark.sql import SparkSession
spark = SparkSession \
.builder \
.appName("Summaries") \
.config("spark.some.config.option", "some-value") \
.getOrCreate()
conf = spark.sparkContext._conf.setAll([('spark.executor.memory', '4g'),
('spark.app.name', 'Spark Updated Conf'),
('spark.driver.cores', '4'), ('spark.executor.cores', '16'),
('spark.driver.memory','90g')])
spark.sparkContext.stop()
spark = SparkSession.builder.config(conf=conf).getOrCreate()
df = spark.read.json("../Data/inasnelylargefile.json.gz")
I assume that the pyspark is doing its magic even while reading a file (so I should see heavy core/memory utilization). But I am not seeing it.Help!
Update: Tested with a smaller zip file (89 MB)
Pyspark take 72 seconds Pandas takes 10.6 seconds Code used :
start = time.time()
df = spark.read.json("../Data/small.json.gz")
end = time.time()
print(end - start)
start = time.time()
df = pa.read_json('../Data/small.json.gz',compression='gzip', lines = True)
end = time.time()
print(end - start)