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

Run include-what-you-use on all patches

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Infrastructure

    Description

      Impala compile times are longer than necessary because .cc files pull in a lot of headers, especially from the standard C++ library and boost. I looked at the preprocessor output for a couple of files, and it included ~400,000 lines of code, almost entirely from headers.

      include-what-you-use is a tool that can identify cases where header includes can be avoided or moved from .h to .cc files to reduce the number of extraneous headers pulled into each compile unit.

      Kudu has some tooling to run IWYU in a dev environment and also in their gerrit precommit.

      I was able to run iwyu against Impala as follows:

      # Clone repo and check out branch to match Impala toolchain's clang version
      git clone https://github.com/include-what-you-use/include-what-you-use.git
      cd include-what-you-use
      git checkout clang_5.0
      
      # Build IWYU against clang from toolchain
      cmake -G "Unix Makefiles" -DIWYU_LLVM_ROOT_PATH=/opt/Impala-Toolchain/llvm-5.0.1-p2/ -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 ..
      make -j $(nproc)
      IWYU_BUILD_DIR=$(pwd)
      
      # Run IWYU on the impala codebase.
      cd $IMPALA_HOME
      # Do an ASAN build to force Impala to generate compile_commands.json with compile commands suitable for clang.
      ./buildall.sh -noclean -notests -asan
      # Placeholder for additional arguments to the iwyu tool
      IWYU_ARGS=""
      PATH=$IWYU_BUILD_DIR:$PATH ~/repos/include-what-you-use/iwyu_tool.py -p . -j $(nproc) -- $IWYU_ARGS > iwyu.txt
      

      Attachments

        1. iwyu_mappings.imp
          2 kB
          Tim Armstrong
        2. iwyu.sh
          0.4 kB
          Tim Armstrong
        3. iwyu2.txt
          2.38 MB
          Tim Armstrong
        4. iwyu4.txt
          1.90 MB
          Tim Armstrong

        Issue Links

        Activity

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

          People

            Unassigned Unassigned
            tarmstrong Tim Armstrong

            Dates

              Created:
              Updated:

              Slack

                Issue deployment