This is an automated email from the ASF dual-hosted git repository.
uros-b pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.x by this push:
new ae63444d7539 [SPARK-59779][DOC] Document the whole-stage codegen
method limit
ae63444d7539 is described below
commit ae63444d753915a532ecb70ab98548a76c5fbb32
Author: Deepak Jain (DJ) <[email protected]>
AuthorDate: Mon Nov 9 11:04:08 2026 +0000
[SPARK-59779][DOC] Document the whole-stage codegen method limit
### What changes were proposed in this pull request?
Add a whole-stage code generation section to the SQL performance tuning
guide. It explains how to recognize methods too large for HotSpot to JIT
compile, when trying a lower `spark.sql.codegen.hugeMethodLimit` can help, and
why the default `65535` does not activate that check. The fallback affects one
codegen stage; other stages can still use generated code.
The setting stays internal and appears only as an advanced option in prose,
with an explicit warning that it has no compatibility guarantee.
Fixes [SPARK-59779](https://issues.apache.org/jira/browse/SPARK-59779).
**JIRA assignee for credit:** deepujain
### Why are the changes needed?
Users seeing `Generated method too long to be JIT compiled` need to
distinguish HotSpot's 8000-byte JIT limit from the JVM's 65535-byte method
limit. The guide connects that diagnostic to the existing tuning option and
tells users to compare performance on their workload before keeping a lower
limit. It also distinguishes this stage fallback from compilation failures
handled by `spark.sql.codegen.fallback`.
### Does this PR introduce _any_ user-facing change?
No. Documentation only; configuration defaults and execution behavior are
unchanged.
### How was this patch tested?
Built the non-API documentation in a Ruby 3.3 container with
`SKIP_ERRORDOC=1 SKIP_API=1 bundle exec jekyll build` and inspected the
rendered section, including the prose-only internal setting and surrounding
sections. Checked the description against `SQLConf`, `WholeStageCodegenExec`,
and `CodeCompiler`; `git diff --check` passed. No code, API docs, or generated
error docs changed.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-6)
Closes #59047 from deepujain/SPARK-59779-document-codegen-limit.
Authored-by: Deepak Jain (DJ) <[email protected]>
Signed-off-by: Uros Bojanic <[email protected]>
(cherry picked from commit 4686647b3a10cec18da27a630994bccecf6660d3)
Signed-off-by: Uros Bojanic <[email protected]>
skip-checks: true
---
docs/sql-performance-tuning.md | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/docs/sql-performance-tuning.md b/docs/sql-performance-tuning.md
index c5f4223ae558..9770327080bd 100644
--- a/docs/sql-performance-tuning.md
+++ b/docs/sql-performance-tuning.md
@@ -451,6 +451,27 @@
spark.sql.optimizer.excludedRules=org.apache.spark.sql.execution.planmerging.Mer
Use exactly that name: the rule was called `MergeScalarSubqueries` before
Spark 4.2 and sat in a different package before Spark 4.3, and unknown names in
`spark.sql.optimizer.excludedRules` are silently ignored, so an older name
carried over from a previous version does not turn the rule off. See the [SQL
migration guide](sql-migration-guide.html) for the old names.
+## Whole-Stage Code Generation
+
+Whole-stage code generation combines operators into generated Java methods. On
HotSpot JVMs with
+`-XX:+DontCompileHugeMethods` enabled (the default), methods larger than 8000
bytes are not JIT
+compiled. Spark logs `Generated method too long to be JIT compiled` when it
encounters such a
+method.
+
+As an advanced tuning option, consider setting
`spark.sql.codegen.hugeMethodLimit` to `8000`.
+This internal setting has no compatibility guarantee and may change in future
releases. It limits
+the bytecode size of a compiled method generated by whole-stage code
generation. If a method exceeds
+this limit, Spark runs that codegen stage without whole-stage code generation;
stages above and
+below it can still use generated code. This setting does not change the JVM's
JIT compilation limit.
+
+The default, `65535`, is the JVM's maximum valid method size, so this check
only takes effect when
+the limit is lowered. A method beyond the JVM limit cannot be compiled into a
class; compilation
+failure is handled separately by `spark.sql.codegen.fallback`.
+
+Compare performance on your workload before retaining a lower limit. Disabling
whole-stage code
+generation can reduce performance, even when a generated method is too large
for HotSpot to JIT
+compile.
+
## Adaptive Query Execution
Adaptive Query Execution (AQE) is an optimization technique in Spark SQL that
makes use of the runtime statistics to choose the most efficient query
execution plan, which is enabled by default since Apache Spark 3.2.0. Spark SQL
can turn on and off AQE by `spark.sql.adaptive.enabled` as an umbrella
configuration.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]