Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Spark produces performance data based on csv dataset #235

Closed
Tom-Deng opened this issue Nov 2, 2021 · 8 comments
Closed

Why Spark produces performance data based on csv dataset #235

Tom-Deng opened this issue Nov 2, 2021 · 8 comments

Comments

@Tom-Deng
Copy link

Tom-Deng commented Nov 2, 2021

The performance of Spark based on the csv dataset is not optimal, but the current performance data of Spark is based on the csv dataset. What is the author's consideration?

@jangorecki
Copy link
Contributor

Do you mean that Spark is not dealing well with CSV data?
It loads the data into memory so CSV is just a source for data. Later on spark operates on an in-memory object and not the CSV.

@Tom-Deng
Copy link
Author

Tom-Deng commented Nov 2, 2021

Do you mean that Spark is not dealing well with CSV data? It loads the data into memory so CSV is just a source for data. Later on spark operates on an in-memory object and not the CSV.
Spark has specifically optimized parquet files. Take q1 of 5G data groupby operation as an example,spark processing csv dataset takes 8.42s on average. but spark processing parquet dataset takes 555ms on average.
csv data:
image
parquet data:
image

@jangorecki
Copy link
Contributor

jangorecki commented Nov 3, 2021

Thanks for investigation. You should try to cache data in memory before running first query, as we do in benchmark script. As of now your code is probably including time to load data from csv in the time of query.

@Tom-Deng
Copy link
Author

Tom-Deng commented Nov 5, 2021

Thanks for investigation. You should try to cache data in memory before running first query, as we do in benchmark script. As of now your code is probably including time to load data from csv in the time of query.
Refer to the suggestions above,I try to cache data in memory before running first query,but the result is basically the same.
image

@jangorecki
Copy link
Contributor

I don't think that your code caches data in memory. Spark interface is lazy and AFAIR calling persist alone does not force computation.

@Tom-Deng
Copy link
Author

Tom-Deng commented Nov 9, 2021

I don't think that your code caches data in memory. Spark interface is lazy and AFAIR calling persist alone does not force computation.

See my code in the attachment, you can take a look at it as a whole.
spark_csv_vs_parquet.ipynb.zip

@jangorecki
Copy link
Contributor

It may be easier if you just run db-benchmark script having data source replaced and compare timings.

@Tom-Deng
Copy link
Author

It may be easier if you just run db-benchmark script having data source replaced and compare timings.
Caching data in memory,the performance of csv and parquet is indeed similar in db-benchmark's scense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants