GitHub user JoshRosen opened a pull request:
https://github.com/apache/spark/pull/13484
[SPARK-15742][SQL] Reduce temp collections allocations in TreeNode
transform methods
In Catalyst's TreeNode transform methods we end up calling
`productIterator.map(...).toArray` in a number of places, which is slightly
inefficient because it needs to allocate an `ArrayBuilder` and grow a temporary
array. Since we already know the size of the final output (`productArity`), we
can simply allocate an array up-front and use a while loop to consume the
iterator and populate the array.
For most workloads, this performance difference is negligible but it does
make a measurable difference in optimizer performance for queries that operate
over very wide schemas (such as the benchmark queries in #13456).
/cc @ericl @marmbrus
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/JoshRosen/spark treenode-productiterator-map
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/13484.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #13484
----
commit 4e7e758d279bd3d1c8de741500f2de51e8cc4ed1
Author: Josh Rosen <[email protected]>
Date: 2016-06-02T23:55:33Z
Improve performance of tree transformation.
commit da79ec6207d4b78d0ebc461cacd37e14d6e4d2e3
Author: Josh Rosen <[email protected]>
Date: 2016-06-02T23:58:24Z
Add comment.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]