[ 
https://issues.apache.org/jira/browse/CALCITE-2509?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Vladimir Sitnikov updated CALCITE-2509:
---------------------------------------
    Description: 
The most trivial case is {{coalesce(v1, v2, v3,...)}}
For instance, it takes 34 seconds to simplify coalesce with 11 inputs.
{noformat}
1, 2 ms, coalesce(vInt(0))
2, 1 ms, coalesce(vInt(0), vInt(1))
3, 3 ms, coalesce(vInt(0), vInt(1), vInt(2))
4, 13 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3))
5, 28 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4))
6, 80 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5))
7, 184 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6))
8, 661 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6), vInt(7))
9, 1872 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6), vInt(7), vInt(8))
10, 7890 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6), vInt(7), vInt(8), vInt(9))
11, 33889 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6), vInt(7), vInt(8), vInt(9), vIntNotNull(0))
{noformat}

{code:java}  @Test
  public void coalesceScalability() {
    checkTrueFalse(vInt());
    RexNode expression;
    for (int j = 1; j < 14; j++) {
      List<RexNode> args = new ArrayList<>();
      for (int i = 0; i < j; i++) {
        args.add(i < 10 ? vInt(i) : vIntNotNull(i % 10));
      }
      expression = coalesce(args.toArray(new RexNode[0]));
      long s = System.currentTimeMillis();
      checkTrueFalse(expression);
      long e = System.currentTimeMillis();
      LOGGER.info(args.size() + ", " + (e - s) + " ms, "
          + expression.accept(new RexToTestCodeShuttle()));
    }

  }
{code}


  was:
The most trivial case is {{coalesce(v1, v2, v3,...)}}
For instance, it takes 34 seconds to simplify coalesce with 11 inputs.
{noformat}
1, 2 ms, coalesce(vInt(0))
2, 1 ms, coalesce(vInt(0), vInt(1))
3, 3 ms, coalesce(vInt(0), vInt(1), vInt(2))
4, 13 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3))
5, 28 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4))
6, 80 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5))
7, 184 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6))
8, 661 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6), vInt(7))
9, 1872 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6), vInt(7), vInt(8))
10, 7890 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6), vInt(7), vInt(8), vInt(9))
11, 33889 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
vInt(6), vInt(7), vInt(8), vInt(9), vIntNotNull(0))
{noformat}



> RexSimplify: withParanoid(true).verify takes exponential time as number of 
> variables grows
> ------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2509
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2509
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>            Priority: Major
>
> The most trivial case is {{coalesce(v1, v2, v3,...)}}
> For instance, it takes 34 seconds to simplify coalesce with 11 inputs.
> {noformat}
> 1, 2 ms, coalesce(vInt(0))
> 2, 1 ms, coalesce(vInt(0), vInt(1))
> 3, 3 ms, coalesce(vInt(0), vInt(1), vInt(2))
> 4, 13 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3))
> 5, 28 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4))
> 6, 80 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5))
> 7, 184 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
> vInt(6))
> 8, 661 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
> vInt(6), vInt(7))
> 9, 1872 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
> vInt(6), vInt(7), vInt(8))
> 10, 7890 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
> vInt(6), vInt(7), vInt(8), vInt(9))
> 11, 33889 ms, coalesce(vInt(0), vInt(1), vInt(2), vInt(3), vInt(4), vInt(5), 
> vInt(6), vInt(7), vInt(8), vInt(9), vIntNotNull(0))
> {noformat}
> {code:java}  @Test
>   public void coalesceScalability() {
>     checkTrueFalse(vInt());
>     RexNode expression;
>     for (int j = 1; j < 14; j++) {
>       List<RexNode> args = new ArrayList<>();
>       for (int i = 0; i < j; i++) {
>         args.add(i < 10 ? vInt(i) : vIntNotNull(i % 10));
>       }
>       expression = coalesce(args.toArray(new RexNode[0]));
>       long s = System.currentTimeMillis();
>       checkTrueFalse(expression);
>       long e = System.currentTimeMillis();
>       LOGGER.info(args.size() + ", " + (e - s) + " ms, "
>           + expression.accept(new RexToTestCodeShuttle()));
>     }
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to