-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-49408][SQL] Use IndexedSeq in ProjectingInternalRow #47890
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
Conversation
296dc8e to
6320ebf
Compare
|
@aokolnychyi Could you please review it? Really thanks! |
|
|
||
| object ProjectingInternalRow { | ||
| def apply(schema: StructType, colOrdinals: Seq[Int]): ProjectingInternalRow = { | ||
| new ProjectingInternalRow(schema, colOrdinals.toIndexedSeq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have benchmark number? cc @yaooqinn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a classic "accidentally quadratic" O(n^2) issue so you could achieve pretty arbitrary speedups with a contrived benchmark.
From the flamegraph attached to https://issues.apache.org/jira/browse/SPARK-49408 it seems like this would make a pretty substantial difference for that test query: it looks like ~94% of the time was being spent in list traversal.
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ProjectingInternalRow.scala
Outdated
Show resolved
Hide resolved
…ectingInternalRow.scala
### What changes were proposed in this pull request? In ProjectingInternalRow, accessing colOrdinals causes poor performace. Replace colOrdinals with the IndexedSeq type. ### Why are the changes needed? Replace colOrdinals with the IndexedSeq type. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No need to add UT ### Was this patch authored or co-authored using generative AI tooling? No Closes #47890 from wzx140/project-row-fix. Lead-authored-by: wzx <[email protected]> Co-authored-by: Kent Yao <[email protected]> Signed-off-by: Kent Yao <[email protected]> (cherry picked from commit 37f2fa9) Signed-off-by: Kent Yao <[email protected]>
### What changes were proposed in this pull request? In ProjectingInternalRow, accessing colOrdinals causes poor performace. Replace colOrdinals with the IndexedSeq type. ### Why are the changes needed? Replace colOrdinals with the IndexedSeq type. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No need to add UT ### Was this patch authored or co-authored using generative AI tooling? No Closes #47890 from wzx140/project-row-fix. Lead-authored-by: wzx <[email protected]> Co-authored-by: Kent Yao <[email protected]> Signed-off-by: Kent Yao <[email protected]> (cherry picked from commit 37f2fa9) Signed-off-by: Kent Yao <[email protected]>
|
Merged to master/3.5/3.4. Thank you all. |
### What changes were proposed in this pull request? In ProjectingInternalRow, accessing colOrdinals causes poor performace. Replace colOrdinals with the IndexedSeq type. ### Why are the changes needed? Replace colOrdinals with the IndexedSeq type. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? No need to add UT ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47890 from wzx140/project-row-fix. Lead-authored-by: wzx <[email protected]> (cherry picked from commit 37f2fa9) Signed-off-by: Kent Yao <[email protected]> Co-authored-by: wzx <[email protected]> Co-authored-by: Kent Yao <[email protected]>
What changes were proposed in this pull request?
In ProjectingInternalRow, accessing colOrdinals causes poor performace. Replace colOrdinals with the IndexedSeq type.
Why are the changes needed?
Replace colOrdinals with the IndexedSeq type.
Does this PR introduce any user-facing change?
No
How was this patch tested?
No need to add UT
Was this patch authored or co-authored using generative AI tooling?
No