Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-3115

LLVM fails to hoist stores out of loops in codegened code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Impala 2.5.0
    • Impala 2.6.0
    • Backend

    Description

      I was looking at the cross-compiled IR (obtained as follows) and noticed that the LLVM optimiser was not hoisting loads and stores out of loops in the various Process*Batch functions for aggs and joins.

      ./toolchain/llvm-3.3-no-asserts-p1/bin/llvm-dis  llvm-ir/impala-sse.bc
      vim llvm-ir/impala-sse.ll
      

      Affected were:

      • RowBatch::num_rows_, RowBatch::num_tuples_per_row_
      • HashTable member vars
      • HashTableCtx member vars

      I confirmed that this had a performance impact by manually hoisting num_rows_ and num_tuples_per_row_ out of the loops into local variables in a few places (see attached patch). Performance improved by ~5% just from doing it in a few places. I imagine we'd see further improvement from doing the same for the hash table member vars.

      I'm not sure exactly what is preventing the optimisation from happening: could be an alias analysis issue (optimiser can't infer that the variables aren't written through a different pointer) or maybe something to do with the loop trip count (optimiser doesn't want to hoist the loads because it can't infer that the pointer will be dereferenced in the loop body).

      Attachments

        1. manual_hoist.patch
          5 kB
          Tim Armstrong
        2. manual_host_performance_result.txt
          7 kB
          Tim Armstrong

        Activity

          People

            kwho Michael Ho
            tarmstrong Tim Armstrong
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: