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-50903][CONNECT] Update plan cache entries after analysis #49584

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

changgyoopark-db
Copy link
Contributor

@changgyoopark-db changgyoopark-db commented Jan 21, 2025

What changes were proposed in this pull request?

Update the plan cache after a plan is analyzed.

Why are the changes needed?

The session local plan cache storing unanalyzed logical plans without updating them causes those plans to be repeatedly analyzed, causing performance degradation.

To be specific, a common usage pattern of the session local plan cache (100%) is,

val plan = planner.transformRelation(request.getPlan.getRoot, cachePlan = true)
val dataframe = Dataset.ofRows(session, plan) 

where an unanalyzed plan may be cached during transformation, and Dataset.ofRows analyzes the unanalyzed plan. This leads to a situation where the same query may hit the cache which in turn returns an unanalyzed plan, and Dataset.ofRows again analyzes the same plan.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

testOnly org.apache.spark.sql.connect.service.SparkConnectSessionHolderSuite

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

No.

@changgyoopark-db changgyoopark-db force-pushed the SPARK-50903 branch 2 times, most recently from db8db47 to 8b1df40 Compare January 21, 2025 11:54
@changgyoopark-db changgyoopark-db changed the title [WIP][SPARK_50903][CONNECT] Let the plan cache only contain analysed plans [SPARK_50903][CONNECT] Let the plan cache only contain analysed plans Jan 21, 2025
@changgyoopark-db changgyoopark-db changed the title [SPARK_50903][CONNECT] Let the plan cache only contain analysed plans [SPARK-50903][CONNECT] Let the plan cache only contain analysed plans Jan 21, 2025
@changgyoopark-db changgyoopark-db changed the title [SPARK-50903][CONNECT] Let the plan cache only contain analysed plans [SPARK-50903][CONNECT] Let the plan cache only contain resolved plans Jan 21, 2025
@changgyoopark-db changgyoopark-db changed the title [SPARK-50903][CONNECT] Let the plan cache only contain resolved plans [SPARK-50903][CONNECT] Let the plan cache only contain analyzed plans Jan 21, 2025
@changgyoopark-db changgyoopark-db force-pushed the SPARK-50903 branch 2 times, most recently from 6fc5c1b to 38d2d1d Compare January 21, 2025 13:38
@changgyoopark-db changgyoopark-db changed the title [SPARK-50903][CONNECT] Let the plan cache only contain analyzed plans [SPARK-50903][CONNECT] Let the plan cache try to analyse plans before storing them Jan 21, 2025
@changgyoopark-db changgyoopark-db force-pushed the SPARK-50903 branch 5 times, most recently from 022f1e3 to 4264bdd Compare January 22, 2025 12:12
@changgyoopark-db changgyoopark-db force-pushed the SPARK-50903 branch 4 times, most recently from e948a7c to 5962637 Compare January 22, 2025 14:19
@changgyoopark-db changgyoopark-db marked this pull request as draft January 23, 2025 13:17
@github-actions github-actions bot removed the PYTHON label Jan 23, 2025
@changgyoopark-db changgyoopark-db changed the title [SPARK-50903][CONNECT] Let the plan cache try to analyse plans before storing them [SPARK-50903][CONNECT] Update plan cache entries after analysis Jan 23, 2025
@changgyoopark-db changgyoopark-db marked this pull request as ready for review January 23, 2025 16:39
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.

1 participant