[
https://issues.apache.org/jira/browse/CALCITE-7965?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated CALCITE-7965:
------------------------------------
Labels: pull-request-available (was: )
> Cache getInputs on SingleRel and BiRel and avoid iterator allocations in
> RelSubset
> ----------------------------------------------------------------------------------
>
> Key: CALCITE-7965
> URL: https://issues.apache.org/jira/browse/CALCITE-7965
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Bruno Volpato
> Priority: Minor
> Labels: pull-request-available
>
> Profiling VolcanoPlanner across multi-way join and TPC-H queries (under both
> TopDownRuleDriver and IterativeRuleDriver) shows that SingleRel.getInputs(),
> BiRel.getInputs(), and RelSubset.inputSubsets() are the largest source of
> transient allocations during optimization:
> * SingleRel and BiRel do not override AbstractRelNode.getInput(int), so even
> rel.getInput(0) allocates a fresh ImmutableList.of(input) or
> FlatLists.of(left, right) on every call (10% to 18% of all allocations under
> TopDown).
> * RelSubset.getParents(), getParentSubsets(), and getParentRels() wrap parent
> inputs through inputSubsets(parent), allocating a SingletonIterator for every
> SingleRel parent (up to 23% of all allocations and 2.5% to 4.9% self CPU).
> We can eliminate these allocations cleanly by overriding getInput(int) on
> SingleRel and BiRel, caching their immutable input lists with an identity
> check against the current input fields (so direct protected field writes in
> subclasses remain safe), and fast-pathing SingleRel and BiRel parents in
> RelSubset without iterator wrappers.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)