[MINOR][CORE] Avoid O(n^2) stack walk in CallerInfo.inBloomFilterStatFunctionCall#12477
Open
LuciferYang wants to merge 1 commit into
Open
[MINOR][CORE] Avoid O(n^2) stack walk in CallerInfo.inBloomFilterStatFunctionCall#12477LuciferYang wants to merge 1 commit into
LuciferYang wants to merge 1 commit into
Conversation
|
Run Gluten Clickhouse CI on x86 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors CallerInfo.inBloomFilterStatFunctionCall in gluten-core to avoid a nested stack.exists that caused an O(n²) walk over the thread stack trace, replacing it with two independent O(n) existence checks while preserving the original (stack-level) semantics.
Changes:
- Replaced nested
stack.existsusage with two independentexistschecks combined via&&. - Added an in-code comment explaining the prior complexity issue and why the refactor is semantically equivalent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
cc @jackylee-ch , a minor fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
CallerInfo.inBloomFilterStatFunctionCallused a nestedstack.existsinside the outer predicate:The inner
stack.existsdoes not depend on the outer element and re-walks the whole stack for every candidate frame, making the check O(n^2) in stack depth. Split it into two independent single-pass checks that combine with&&; the resulting predicate is "the stack contains both aDataFrameStatFunctionsframe and abloomFilterframe," identical to the original.Why are the changes needed?
CallerInfo.create()is invoked once per columnar rule application, so this predicate runs on every planned query. The change is a straight refactor with no behavior difference; the value is that the stack scan drops from quadratic to linear.Does this PR introduce any user-facing change?
No.
How was this patch tested?
mvn -pl gluten-core -Pspark-3.5 spotless:checkandcompilepass. No behavior change, no new test.