Skip to content

[SPARK-51559][SQL] Make max broadcast table size configurable#50327

Closed
sunchao wants to merge 2 commits intoapache:masterfrom
sunchao:SPARK-51559
Closed

[SPARK-51559][SQL] Make max broadcast table size configurable#50327
sunchao wants to merge 2 commits intoapache:masterfrom
sunchao:SPARK-51559

Conversation

@sunchao
Copy link
Copy Markdown
Member

@sunchao sunchao commented Mar 19, 2025

What changes were proposed in this pull request?

Currently the maximum size for a table to be broadcast in BroadcastExchangeExec is hard-coded to 8GB, and it seems there is no particular reason why this value was picked initially. In certain scenarios, we may want broadcast hash join to be triggered even with larger table sizes, since otherwise it will fallback to expensive shuffle join.

Why are the changes needed?

This PR introduces a new configuration: spark.sql.maxBroadcastTableSize, which by default still uses 8GB, so no behavior change expected. This would allow users to update the config when necessary to be more flexible.

Does this PR introduce any user-facing change?

No behavior change. Only a new config is added.

How was this patch tested?

We tested out this internally and it seems to be working well.

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

No

@github-actions github-actions bot added the SQL label Mar 19, 2025
@sunchao
Copy link
Copy Markdown
Member Author

sunchao commented Mar 19, 2025

cc @viirya @dongjoon-hyun @cloud-fan


val MAX_BROADCAST_TABLE_SIZE = buildConf("spark.sql.maxBroadcastTableSize")
.doc("The maximum table size that can be broadcast in broadcast joins.")
.version("4.0.0")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4.1.0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup updated

Copy link
Copy Markdown
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM for Apache Spark 4.1.0.

You know that you can backport this Apache Spark 4.1.0 commit to the internal fork. :)

.createWithDefaultString(s"${5 * 60}")

val MAX_BROADCAST_TABLE_SIZE = buildConf("spark.sql.maxBroadcastTableSize")
.doc("The maximum table size that can be broadcast in broadcast joins.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.doc("The maximum table size that can be broadcast in broadcast joins.")
.doc("The maximum table size in bytes that can be broadcast in broadcast joins.")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sunchao
Copy link
Copy Markdown
Member Author

sunchao commented Mar 19, 2025

You know that you can backport this Apache Spark 4.1.0 commit to the internal fork. :)

Haha our internal folk already has the commit :)

@sunchao sunchao closed this in cfe1b39 Mar 19, 2025
@sunchao
Copy link
Copy Markdown
Member Author

sunchao commented Mar 19, 2025

Thanks! merged to master.

@cloud-fan
Copy link
Copy Markdown
Contributor

late LGTM

zhouyuan pushed a commit to apache/gluten that referenced this pull request Apr 18, 2025
Port apache/spark#50327 to make max broadcast table size configurable.

Also, remove our hardcoded ones and make some custom spark build happy
@pratham76
Copy link
Copy Markdown
Contributor

@sunchao @dongjoon-hyun Is it possible that we could backport this change for spark 3.5 and 4.0 as well? This also helps when broadcast hints are used to optimize queries involving slightly larger tables (> 8GB). Do let me know if i can contribute. Thanks!

pratham76 pushed a commit to pratham76/spark that referenced this pull request Mar 1, 2026
pratham76 pushed a commit to pratham76/spark that referenced this pull request Mar 1, 2026
pratham76 pushed a commit to pratham76/spark that referenced this pull request Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants