[
https://issues.apache.org/jira/browse/CALCITE-7964?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated CALCITE-7964:
------------------------------------
Labels: pull-request-available (was: )
> Avoid redundant lookups and boxing in RelTraitSet and RelFieldCollation
> -----------------------------------------------------------------------
>
> Key: CALCITE-7964
> URL: https://issues.apache.org/jira/browse/CALCITE-7964
> 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
> IterativeRuleDriver and TopDownRuleDriver) shows significant CPU and
> allocation overhead in RelTraitSet and RelFieldCollation:
> * RelFieldCollation.hashCode() calls Objects.hash(fieldIndex, direction,
> nullDirection), allocating an Object[3] varargs array and boxing fieldIndex
> on every lookup (1.1% to 1.8% of total VolcanoPlanner allocations under
> TopDown).
> * RelTraitSet.findIndex(RelTraitDef) scans traits[] linearly on every
> getConvention(), getCollation(), getDistribution(), equalsSansConvention(),
> and getDefaultSansConvention() call (1.3% to 6.2% self CPU).
> * RelTraitSet.satisfies(RelTraitSet) dispatches virtual RelTrait.satisfies()
> even when both slots hold the exact same canonical trait instance, and
> RelCollationImpl.satisfies() enters Util.startsWith() even when the target
> collation is empty.
> * RelTraitSet.getDefault() and getDefaultSansConvention() recompute default
> trait sets even when the receiver already holds default traits.
> We can eliminate these overheads without changing public APIs or hash values
> by computing the exact Objects.hash arithmetic directly in
> RelFieldCollation.hashCode(), precomputing byte indices for the three
> built-in trait defs in RelTraitSet's private constructor (with linear
> fallback for custom trait defs and indices >= 128), adding identity/empty
> fast paths in satisfies(), and short-circuiting/caching getDefault() and
> getDefaultSansConvention().
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)