Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5277

Make EnumerableRelImplementor stashedParameters order deterministic to increase BINDABLE_CACHE hit rate

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.32.0
    • core

    Description

      Currently, EnumerableRelImplementor stashedParameters is a map with no deterministic order when its values are traversed.
      Because of this, it is possible to have two EnumerableRel which are effectively equal, but which generate a different dynamic code, just because the statements in which stashedParameters are defined are the same, but in different order.

          final Collection<Statement> stashed =
              Collections2.transform(stashedParameters.values(),
                  input -> Expressions.declare(Modifier.FINAL, input,
                      Expressions.convert_(
                          Expressions.call(DataContext.ROOT,
                              BuiltInMethod.DATA_CONTEXT_GET.method,
                              Expressions.constant(input.name)),
                          input.type)));
      

      This has a disadvantage: in this situation, EnumerableInterpretable's BINDABLE_CACHE will not have a cache hit, so the Bindable will need to be unnecessarily recreated in EnumerableInterpretable#getBindable.
      If we guarantee a deterministic order in EnumerableRelImplementor stashedParameters (e.g. insertion order), we would have a cache hit in these situations (and we could skip the bindable re-creation).

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            rubenql Ruben Q L
            rubenql Ruben Q L
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 50m
                50m

                Slack

                  Issue deployment