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

Spark first time longer #28

Closed
mattdowle opened this issue Sep 11, 2018 · 5 comments
Closed

Spark first time longer #28

mattdowle opened this issue Sep 11, 2018 · 5 comments
Labels

Comments

@mattdowle
Copy link
Contributor

Comment from Michael on Twitter here :

https://twitter.com/michael_chirico/status/1039356873760112641

Noticing that the first run of the first Spark benchmark is slow... I assume it's including the start-up time of the cluster?

It seems proportional to the data size, though. What's happening there and is there a way to isolate it and report separately perhaps.

@jangorecki
Copy link
Contributor

jangorecki commented Sep 12, 2018

To clarify @MichaelChirico concerns, first run on Spark does not include start-up time of cluster (in this case a single node cluster). Cluster is already started and data were read into it, cached into memory.

Already had little discussion on that with @st-pasha and problem is not trivial to resolve.

The non trivial parts are:

  • how deep warm up should be, different solutions might benefit differently from warm-up, larger warm-up might give better improvement for one solution and lower for another. For example data.table has minor overhead as described in speed up first [.data.table call.
  • what is the subject of benchmark, if we want to simulate an user workflow where first query suffers from that overhead, then it makes perfect sense to keep it. If we agree that an user before doing his processing always runs some warm-up on his node, then of course make sense to do warm-up.

As for now I am not seeing reasons good enough, and strategy fair enough, to include warming up solutions for "groupby" task.
What looks to be proper way to address that is to add new task for grouping on warmed-up/analyzed/sorted/indexed data.

@mattdowle
Copy link
Contributor Author

mattdowle commented Sep 17, 2018

The dataset is being loaded from file I think. Could it be that Spark is very fast at file load but isn't materializing the data. Then when the first group by comes along, that's when it actually does the load from file. (Adding load times to the report was on the todo list regardless.) If lazy data ingest doesn't explain it, can an issue be raised in spark SO tag or code-review site to see if they know.

@MichaelChirico
Copy link
Contributor

@mattdowle I'm not sure whether this is what's going on, but yes, operations are generally lazy in Spark.

This code will be almost instant:

spark.read.parquet('s3://path/to/folder')

Even adding some filtering & basic things will do nothing.

Can force-overcome lazy eval by doing something inexpensive like:

SDF = spark.read.parquet('s3://path/to/folder')
SDF.count()

Open to debate whether something like SDF.cache() is legit for comparison

@jangorecki
Copy link
Contributor

jangorecki commented Sep 17, 2018

  • It is likely that spark csv reading time is included in the first grouping time. I will add .count() before grouping as suggested by Michael, but it has to be added for all tools, as this is already "collecting statistics" about the data.
  • It is desired to use .cache, otherwise spark would be re-reading csv on each query(?, according to design). It is even more desired to use .cache for results of queries, other tools do cache answer on side, and it can be accessed later on, unlike AFAIR impala and presto where you needed to use CREATE TABLE AS SELECT to actually keep query results.
  • Instead of .cache method we use .persist(pyspark.StorageLevel.MEMORY_ONLY) as in recent versions of spark .cache only wraps to .persist but does not let you to chose MEMORY_ONLY. This has to be adjusted when we go for 1e10 grouping benchmark (500GB) to .persist to memory and disk.

@jangorecki
Copy link
Contributor

Solved in a26b8af

jangorecki added a commit to jangorecki/db-benchmark that referenced this issue Jul 24, 2023
* nicely close connection to avoid warnings

* missing DBI prefix and con var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants